-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c9d5fd1
commit 36a7183
Showing
19 changed files
with
181 additions
and
569 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
using Autodesk.Revit.Attributes; | ||
using Autodesk.Revit.DB.ExtensibleStorage; | ||
using BimIshou.Services; | ||
using Nice3point.Revit.Toolkit.External; | ||
using ricaun.Revit.DI; | ||
using System.Diagnostics; | ||
|
||
namespace BimIshou.Commands | ||
{ | ||
[Transaction(TransactionMode.Manual)] | ||
public class TestDI : ExternalCommand, IHost | ||
{ | ||
public override void Execute() | ||
{ | ||
Host.Container.AddRevitSingleton(UiApplication); | ||
Host.Container.AddSingleton<IProjectInfoService, ProjectInfoService>(); | ||
|
||
var xxx = Host.Container.Resolve<IProjectInfoService>(); | ||
var format = xxx.GetProjectInfo(ConstantGUID.SchemaGUID_LoggerParking, nameof(LoggerParkingEnum.Format)); | ||
var RowNumber = xxx.GetProjectInfo(ConstantGUID.SchemaGUID_LoggerParking, nameof(LoggerParkingEnum.RowNumber)); | ||
|
||
|
||
Debug.WriteLine(RowNumber); | ||
} | ||
} | ||
public enum LoggerParkingEnum | ||
{ | ||
Format, | ||
Type, | ||
ProductType, | ||
RowNumber, | ||
SpanX, | ||
SpanY, | ||
SpotType, | ||
SpotCount, | ||
IndexEntry, | ||
SlopeType, | ||
SlopePos, | ||
FloorCount, | ||
SpecClimateArea, | ||
TotalAcreageContruction, | ||
AcreageAFloor, | ||
ElevatorCount, | ||
StairCount, | ||
GroupProductName | ||
} | ||
public static class ConstantGUID | ||
{ | ||
public static Schema GetGuid(this string stringGuid) | ||
{ | ||
return Schema.Lookup(new Guid(stringGuid)); | ||
} | ||
public const string SchemaGUID_GDSettings = "C3DB751D-5032-44A2-BBAE-AFCDB8ABA7CF"; | ||
public const string SchemaGUID_Input6Storage = "50DFBF8C-E182-4909-B9EC-A8FC9643DC13"; | ||
public const string SchemaGUID_Input5Settings = "A67646E2-5EC2-4745-9B6C-47706EDF6585"; | ||
public const string SchemaGUID_Input4BoxStorage = "C70DD2ED-78D4-44BC-8941-A299798AE1EF"; | ||
public const string SchemaGUID_LoggerParking = "96190439-48E7-4C1C-A537-6F95EB281C78"; | ||
public const string SchemaGUID_OutputParking = "4B9E3E1B-8D1B-4A64-8B55-A068F01ADB4E"; | ||
public const string SchemaGUID_OutputGD = "533E9DB4-F1F8-443F-BD5B-19AA03D423D2"; | ||
public const string SchemaGUID_CustomEntry = "0dc622fc-cdd7-4bec-8243-250d1d41ea44"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using ricaun.DI; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace BimIshou | ||
{ | ||
public static class Host | ||
{ | ||
public static IContainer Container { get; } = ContainerUtils.CreateContainer(); | ||
public static IContainerResolver ContainerResolver => Container; | ||
public static T Resolve<T>() where T : class => ContainerResolver.Resolve<T>(); | ||
public static T ResolveOrNull<T>() where T : class => ContainerResolver.ResolveOrNull<T>(); | ||
} | ||
|
||
public interface IHost { } | ||
public static class HostExtension | ||
{ | ||
public static IContainer GetContainer(this IHost _) => Host.Container; | ||
public static IContainerResolver GetContainerResolver(this IHost _) => Host.ContainerResolver; | ||
public static T Resolve<T>(this IHost _) where T : class => Host.Resolve<T>(); | ||
public static T ResolveOrNull<T>(this IHost _) where T : class => Host.ResolveOrNull<T>(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using Autodesk.Revit.DB; | ||
using Autodesk.Revit.UI; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace RevitAddin.DI.Example.Services | ||
{ | ||
public class DocumentService : IDocumentService | ||
{ | ||
private readonly UIApplication uiapp; | ||
|
||
public DocumentService(UIApplication uiapp) | ||
{ | ||
this.uiapp = uiapp; | ||
} | ||
|
||
public Document GetDocument() | ||
{ | ||
return uiapp.ActiveUIDocument.Document; | ||
} | ||
|
||
public IList<Document> GetDocuments() | ||
{ | ||
return uiapp.Application.Documents | ||
.OfType<Document>() | ||
.ToList(); | ||
} | ||
|
||
} | ||
|
||
public interface IDocumentService | ||
{ | ||
public Document GetDocument(); | ||
public IList<Document> GetDocuments(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using Autodesk.Revit.DB; | ||
using Autodesk.Revit.UI; | ||
using BimIshou.Commands; | ||
|
||
namespace BimIshou.Services | ||
{ | ||
class ProjectInfoService : IProjectInfoService | ||
{ | ||
Document Document; | ||
public ProjectInfoService(UIApplication uiapp) | ||
{ | ||
Document = uiapp.ActiveUIDocument.Document; | ||
} | ||
|
||
public string GetProjectInfo(string Guid, string name) | ||
{ | ||
return Document.ProjectInformation.LoadEntity<string>(Guid.GetGuid(), name); | ||
} | ||
} | ||
|
||
public interface IProjectInfoService | ||
{ | ||
public string GetProjectInfo(string Guid, string name); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.