本文整理汇总了C#中Dependency类的典型用法代码示例。如果您正苦于以下问题:C# Dependency类的具体用法?C# Dependency怎么用?C# Dependency使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Dependency类属于命名空间,在下文中一共展示了Dependency类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Check
public void Check(ConstructorInfo info, Dependency parent)
{
if (info.IsPrivate && !info.ReflectedType.IsAbstract)
{
parent.Add(new ProblemDependency(string.Format("This is a private constructor")));
}
}
开发者ID:royosherove,项目名称:dotnet-depender,代码行数:7,代码来源:FindPrivateConstructorsOnNonAbstractClassesRule.cs
示例2:
public static SqlServerDocumentDbRegistration RegisterSqlServerDocumentDb
(this IWindsorContainer @this,
SqlServerDocumentDbRegistration registration,
string connectionName,
Dependency sessionInterceptor = null)
{
Contract.Requires(registration != null);
Contract.Requires(!connectionName.IsNullOrWhiteSpace());
//We don't want to get any old interceptor that might have been registered by someone else.
sessionInterceptor = sessionInterceptor ?? Dependency.OnValue<IDocumentDbSessionInterceptor>(NullOpDocumentDbSessionInterceptor.Instance);
var connectionString = Dependency.OnValue(typeof(string),@this.Resolve<IConnectionStringProvider>().GetConnectionString(connectionName).ConnectionString);
@this.Register(
Component.For<IDocumentDb>()
.ImplementedBy<SqlServerDocumentDb>()
.DependsOn(connectionString)
.LifestylePerWebRequest()
.Named(registration.DocumentDbName),
Component.For(Seq.OfTypes<IDocumentDbSession, IDocumentDbUpdater, IDocumentDbReader, IDocumentDbBulkReader, IUnitOfWorkParticipant, IDocumentUpdatedNotifier>())
.ImplementedBy<DocumentDbSession>()
.DependsOn(registration.DocumentDb, sessionInterceptor)
.LifestylePerWebRequest()
.Named(registration.SessionName)
);
@this.WhenTesting()
.ReplaceDocumentDb(registration.DocumentDbName);
return registration;
}
示例3: Check
public void Check(MethodInfo info, Dependency parent)
{
if (!info.IsFinal && (info.IsVirtual || info.IsAbstract))
{
parent.Add(new Dependency(string.Format(" {0}() can be overriden", info.Name)));
}
}
示例4: Standard
public void Standard() {
var dep = new Dependency("@cba_a3-1.0.0.4");
dep.Name.Should().Be("@cba_a3");
dep.Version.Should().Be("1.0.0.4");
dep.Branch.Should().BeNull();
}
示例5: SpecialVersion
public void SpecialVersion() {
var dep = new Dependency("@cba_a3-1983.12.24");
dep.Name.Should().Be("@cba_a3");
dep.Version.Should().Be("1983.12.24");
dep.Branch.Should().BeNull();
}
示例6: SpecialVersionConstraintsWithBranch
public void SpecialVersionConstraintsWithBranch() {
var dep = new Dependency("@cba_a3->=1.0.0.4-beta");
dep.Name.Should().Be("@cba_a3");
dep.Version.Should().Be(">=1.0.0.4");
dep.Branch.Should().Be("beta");
}
示例7: JustName
public void JustName() {
var dep = new Dependency("@cba_a3");
dep.Name.Should().Be("@cba_a3");
dep.Version.Should().BeNull();
dep.Branch.Should().BeNull();
}
示例8: SpecialName2
public void SpecialName2() {
var dep = new Dependency("@cba_a3-xx-1-1-1.0.2-beta");
dep.Name.Should().Be("@cba_a3-xx-1-1");
dep.Version.Should().Be("1.0.2");
dep.Branch.Should().Be("beta");
}
示例9: CollectsAllBindingsAndLoadsThemDistinctOnKernel
public void CollectsAllBindingsAndLoadsThemDistinctOnKernel()
{
var loadedModules = new List<INinjectModule>();
A.CallTo(() => this.kernel.Load(A<IEnumerable<INinjectModule>>._))
.Invokes((IEnumerable<INinjectModule> modules) => loadedModules.AddRange(modules));
var dependencyA = new DependencyA();
var dependencyB = new DependencyB();
var dependencyDefinitionA = new Dependency<IDependencyA>(bind => bind.ToConstant(dependencyA).InTransientScope());
var dependencyDefinitionB = new Dependency<IDependencyB>(bind => bind.ToConstant(dependencyB).InSingletonScope());
this.testee.Load(
new FeatureA(
dependencyDefinitionA,
dependencyDefinitionB),
new FeatureB(
dependencyDefinitionA,
dependencyDefinitionB),
new FeatureC());
loadedModules.Select(_ => _.GetType().Name)
.Should().Contain(
new[]
{
typeof(ModuleA),
typeof(ModuleB),
typeof(ModuleC),
typeof(ModuleD)
}.Select(_ => _.Name))
.And.BeEquivalentTo(loadedModules.Select(_ => _.GetType().Name).Distinct());
}
示例10: RegisterDependency
/// <summary>
/// 注册依赖服务对象
/// </summary>
/// <param name="dependency">依赖服务对象</param>
/// <exception cref="ArgumentNullException"></exception>
public void RegisterDependency(Dependency dependency)
{
if (dependency == null)
throw new ArgumentNullException(nameof(dependency));
_container.Add(dependency);
}
示例11: ConvertIdentifier
private object ConvertIdentifier(
object value,
Item item,
Direction direction,
Guid providerId,
string itemType)
{
if (value != null && !string.IsNullOrWhiteSpace(value.ToString()))
{
if (direction == Direction.Packaging)
{
var guid = Dependencies.ConvertIdentifier(value.ToString(), IdentifierReplaceDirection.FromNodeIdToGuid);
// add dependency for the item
var name = string.Concat(itemType, " from picker");
var dependency = new Dependency(name, guid, providerId);
item.Dependencies.Add(dependency);
return guid;
}
else if (direction == Direction.Extracting)
{
return Dependencies.ConvertIdentifier(value.ToString(), IdentifierReplaceDirection.FromGuidToNodeId);
}
}
return value;
}
示例12: IsMajorConflict_returns_false_for_identical_version_numbers
public void IsMajorConflict_returns_false_for_identical_version_numbers() {
var dependency = new Dependency();
dependency.LibAssembly = GetNewAssemblyNameWithVersion(1, 2, 3, 4);
dependency.ReferencedAssembly = GetNewAssemblyNameWithVersion(1, 2, 3, 4);
Assert.That(dependency.IsMajorConflict, Is.False, "should not report a conflict if the version numbers are identical");
}
示例13: Check
public void Check(FieldInfo info, Dependency parent)
{
// Dependency parent = new Dependency(info.);
bool isInterface = info.FieldType.IsInterface;
bool isAbstract = info.FieldType.IsAbstract;
bool isNotSealed = !info.FieldType.IsSealed;
string message = "";
if (isInterface)
{
message = string.Format("Field {0} is interface {1}", info.Name, info.FieldType.Name);
}
else if (isAbstract)
{
message = string.Format("Field {0} is an abstract class {1} and can be inherited from", info.Name,info.FieldType.Name);
}
else if (isNotSealed)
{
message =
string.Format("Field {0} is non sealed {1} and can be inherited from", info.Name,
info.FieldType.Name);
}
parent.Add(new Dependency(message));
// if (parent.AlreadyContains(info.FieldType))
// {
// parent.Add(new Dependency(message));
// }
// else
// {
// parent.Add(new Dependency(info.FieldType, message));
// }
}
示例14: IsConflicted_returns_true_for_conflict_of_nonbreaking_change_number
public void IsConflicted_returns_true_for_conflict_of_nonbreaking_change_number()
{
var dependency = new Dependency();
dependency.LibAssembly = GetNewAssemblyNameWithVersion(1, 2, 5, 4);
dependency.ReferencedAssembly = GetNewAssemblyNameWithVersion(1, 2, 3, 4);
Assert.That(dependency.IsConflicted, Is.True, "should report a minor conflict if the version numbers are not the same");
}
示例15: IsMajorConflict_returns_false_for_version_numbers_with_only_3rd_and_4th_number_different
public void IsMajorConflict_returns_false_for_version_numbers_with_only_3rd_and_4th_number_different()
{
var dependency = new Dependency();
dependency.LibAssembly = GetNewAssemblyNameWithVersion(1, 2, 5, 4);
dependency.ReferencedAssembly = GetNewAssemblyNameWithVersion(1, 2, 3, 8);
Assert.That(dependency.IsMajorConflict, Is.False, "should not report a conflict if the version numbers are same except for 3rd and 4th numbers");
}