コード例 #1
0
            internal ComponentInfo(Type interfaceType, string kind, Type argumentType, TlcModule.ComponentAttribute attribute)
            {
                Contracts.AssertValue(interfaceType);
                Contracts.AssertNonEmpty(kind);
                Contracts.AssertValue(argumentType);
                Contracts.AssertValue(attribute);

                Name        = attribute.Name;
                Description = attribute.Desc;
                if (string.IsNullOrWhiteSpace(attribute.FriendlyName))
                {
                    FriendlyName = Name;
                }
                else
                {
                    FriendlyName = attribute.FriendlyName;
                }

                Kind = kind;
                if (!IsValidName(Kind))
                {
                    throw Contracts.Except("Invalid component kind: '{0}'", Kind);
                }

                Aliases = attribute.Aliases;
                if (!IsValidName(Name))
                {
                    throw Contracts.Except("Component name '{0}' is not valid.", Name);
                }

                if (Aliases != null && Aliases.Any(x => !IsValidName(x)))
                {
                    throw Contracts.Except("Component '{0}' has an invalid alias '{1}'", Name, Aliases.First(x => !IsValidName(x)));
                }

                if (!typeof(IComponentFactory).IsAssignableFrom(argumentType))
                {
                    throw Contracts.Except("Component '{0}' must inherit from IComponentFactory", argumentType);
                }

                ArgumentType  = argumentType;
                InterfaceType = interfaceType;
            }
コード例 #2
0
            internal LoadableClassInfo(LoadableClassAttributeBase attr, MethodInfo getter, ConstructorInfo ctor, MethodInfo create, bool requireEnvironment)
            {
                Contracts.AssertValue(attr);
                Contracts.AssertValue(attr.InstanceType);
                Contracts.AssertValue(attr.LoaderType);
                Contracts.AssertValueOrNull(attr.Summary);
                Contracts.AssertValueOrNull(attr.DocName);
                Contracts.AssertValueOrNull(attr.UserName);
                Contracts.AssertNonEmpty(attr.LoadNames);
                Contracts.Assert(getter == null || Utils.Size(attr.CtorTypes) == 0);

                Type       = attr.InstanceType;
                LoaderType = attr.LoaderType;
                Summary    = attr.Summary;
                UserName   = attr.UserName;
                LoadNames  = attr.LoadNames.AsReadOnly();

                if (getter != null)
                {
                    InstanceGetter = getter;
                }
                else if (ctor != null)
                {
                    Constructor = ctor;
                }
                else if (create != null)
                {
                    CreateMethod = create;
                }
                ArgType            = attr.ArgType;
                SignatureTypes     = attr.SigTypes.AsReadOnly();
                CtorTypes          = attr.CtorTypes ?? Type.EmptyTypes;
                RequireEnvironment = requireEnvironment;

                if (!string.IsNullOrWhiteSpace(attr.DocName))
                {
                    DocName = attr.DocName;
                }

                Contracts.Assert(ArgType == null || CtorTypes.Length > 0 && CtorTypes[0] == ArgType);
            }
コード例 #3
0
 private static object[] ConcatArgsRev(object[] args2, params object[] args1)
 {
     Contracts.AssertNonEmpty(args1);
     return(Utils.Concat(args1, args2));
 }