Exemple #1
0
        protected override IMapsDirectlyToDatabaseTable ConstructEntity(Type t, DbDataReader reader)
        {
            if (Constructors.ContainsKey(t))
            {
                return(Constructors[t](this, reader));
            }

            return(_constructor.ConstructIMapsDirectlyToDatabaseObject <ICatalogueRepository>(t, this, reader));
        }
Exemple #2
0
        public void SelectReturnsCorrectConstructor()
        {
            var expected = TypeWithCtors.Ctor;
            var actual   = Constructors.Select(() => new TypeWithCtors());

            Assert.Equal(expected, actual);
        }
Exemple #3
0
        /// <summary>
        /// Selects a constructor that initializes the most properties
        /// </summary>
        public ConstructorInfo SelectIdealConstructor()
        {
            ConstructorInfo  idealConstructor = null;
            HashSet <string> propertyNames    = Properties.Select(prop => prop.Name.ToLower()).ToHashSet();

            string[] _matches = new string[] { };

            foreach (ConstructorInfo constructor in Constructors)
            {
                ParameterInfo[]  parameters     = constructor.GetParameters();
                HashSet <string> parameterNames = parameters.Select(param => param.Name.ToLower()).ToHashSet();
                string[]         matches        = parameterNames.Intersect(propertyNames).ToArray();
                if (matches.Length > _matches.Length)
                {
                    _matches         = matches;
                    idealConstructor = constructor;
                }
            }

            // there is only a default constructor with no parameters
            if (idealConstructor == null)
            {
                idealConstructor = Constructors.First();
            }

            return(idealConstructor);
        }
Exemple #4
0
        private static void InstallAnimations(RectTransformElement rte, GameObject gameObject, IReadOnlyLayoutContext context)
        {
            AnimationContext animationContext = new AnimationContext();

            List <(UIAnimation, AnimationElement)> listOfAnimations = new List <(UIAnimation, AnimationElement)>();

            foreach (var anim in rte.Animations)
            {
                var         constructor = Constructors.GetAnimationConstructor(anim);
                UIAnimation animation   = constructor.Install(gameObject, anim, context);

                if (!string.IsNullOrEmpty(anim.Key))
                {
                    animationContext.AddAnimation(context.ParseString(anim.Key), animation);
                }

                listOfAnimations.Add((animation, anim));
            }

            foreach (var pair in listOfAnimations)
            {
                var anim      = pair.Item2;
                var animation = pair.Item1;
                foreach (var trigger in anim.Triggers)
                {
                    var       constructor      = Constructors.GetTriggerConstructor(trigger);
                    UITrigger triggerComponent = constructor.Install(gameObject, trigger, context, animationContext);

                    triggerComponent.conditions = ParseConditions(trigger.Conditions, gameObject, context);
                    triggerComponent.instant    = context.ParseBool(trigger.Instant);
                    triggerComponent.animation  = animation;
                }
            }
        }
Exemple #5
0
        public void WriteConstructor(DataNode node)
        {
            var constructorWriter = new ConstructorWriter(this, node);

            Constructors.Add(constructorWriter);
            constructorWriter.Process();
        }
        public TypeModel ToModel()
        {
            TypeModel model = new TypeModel();

            model.TypeEnum         = EnumMapper.ConvertEnum <TypeTypesEnum, TypeTypesSerializationModelEnum>(TypeEnum);
            model.TypeName         = TypeName;
            model.NamespaceName    = NamespaceName;
            model.GenericArguments = GenericArguments?.Select(EmitTypeModel);

            model.Modifiers = new Tuple <AccessLevelEnum, SealedEnum, AbstractEnum>(
                EnumMapper.ConvertEnum <AccessLevelEnum, AccessLevelSerializationModelEnum>(Modifiers.Item1),
                EnumMapper.ConvertEnum <SealedEnum, SealedSerializationModelEnum>(Modifiers.Item2),
                EnumMapper.ConvertEnum <AbstractEnum, AbstractSerializationModelEnum>(Modifiers.Item3));

            model.Attributes            = Attributes?.Select(attributeMetadata => attributeMetadata.ToModel());
            model.FullTypeName          = FullTypeName;
            model.DeclaringType         = DeclaringType == null ? null : EmitTypeModel(DeclaringType);
            model.BaseType              = DeclaringType == null ? null : EmitTypeModel(BaseType);
            model.ImplementedInterfaces = ImplementedInterfaces?.Select(EmitTypeModel);
            model.Fields       = Fields?.Select(typeModel => typeModel.ToModel());
            model.Methods      = Methods?.Select(typeModel => typeModel.ToModel());
            model.Properties   = Properties?.Select(typeModel => typeModel.ToModel());
            model.Indexers     = Indexers?.Select(typeModel => typeModel.ToModel());
            model.Events       = Events?.Select(typeModel => typeModel.ToModel());
            model.Constructors = Constructors?.Select(typeModel => typeModel.ToModel());
            model.NestedTypes  = NestedTypes?.Select(EmitTypeModel);

            return(model);
        }
 public override void VisitConstructorDeclaration(ConstructorDeclarationSyntax Node)
 {
     base.VisitConstructorDeclaration(Node);
     Constructors.Add(
         this.ParseMethod(Node.Identifier, null, Node.Modifiers, Node.ParameterList)
         );
 }
		void CachesAsExpected( Constructors constructors, int number )
		{
			var parameter = new ConstructTypeRequest( typeof(ConstructedItem), number );
			var first = constructors.Get( parameter );
			Assert.Same( first, constructors.Get( parameter ) );
			Assert.Equal( number, new ConstructedItem( number ).Number );
		}
Exemple #9
0
        void AddConstructors(ClassGen klass, CodeGenerationOptions opt, CodeGeneratorContext context)
        {
            // Add required constructor for all JLO inheriting classes
            if (klass.FullName != "Java.Lang.Object" && klass.InheritsObject)
            {
                Constructors.Add(new JavaLangObjectConstructor(klass));
            }

            foreach (var ctor in klass.Ctors)
            {
                // Don't bind final or protected constructors
                if (klass.IsFinal && ctor.Visibility == "protected")
                {
                    continue;
                }

                // Bind Java declared constructor
                Constructors.Add(new BoundConstructor(klass, ctor, klass.InheritsObject, opt, context));

                // If the constructor takes ICharSequence, create an overload constructor that takes a string
                if (ctor.Parameters.HasCharSequence && !klass.ContainsCtor(ctor.JniSignature.Replace("java/lang/CharSequence", "java/lang/String")))
                {
                    Constructors.Add(new StringOverloadConstructor(klass, ctor, klass.InheritsObject, opt, context));
                }
            }
        }
Exemple #10
0
        public void ConstructorInvokeTest()
        {
            var constructors = new Constructors();
            var messageType  = typeof(Message).GetTypeData();

            var case1 = new InvokeTestCase
            {
                ConstructorData = messageType.Constructors.Get(new Name(constructors.DefaultConstructor)),
                Parameters      = new object[0],
                Value           = string.Empty
            };

            var case2 = new InvokeTestCase
            {
                ConstructorData = messageType.Constructors.Get(new Name(constructors.NotDefaultConstructor)),
                Parameters      = new object[] { "test" },
                Value           = "test"
            };

            Run(Test, case1, case2);

            void Test(InvokeTestCase testCase)
            {
                AreEqual(testCase.Value, testCase.ConstructorData.Invoke <Message>(testCase.Parameters).Value);
            }
        }
Exemple #11
0
        // Nested indent have to be set for each Nested element and subelement separately, or after generation manualy to select nested code and indent it with tab
        // Setting it automaticaly and propagating could be done if the parent sets the child's parent reference (to itself) when the child is added/assigned to a parent. Parent setter is internal.
        //   http://softwareengineering.stackexchange.com/questions/261453/what-is-the-best-way-to-initialize-a-childs-reference-to-its-parent

        public override string ToString()
        {
            string result = base.ToString();

            result += (BaseClass != null || Interfaces?.Count > 0) ? $" : " : "";
            result += BaseClass != null ? BaseClass : "";
            result += (BaseClass != null && Interfaces?.Count > 0) ? $", " : "";
            result += Interfaces?.Count > 0 ? string.Join(", ", Interfaces) : "";
            result += Util.NewLine + Indent + "{";

            result += String.Join("", Fields);

            var  visibleConstructors        = Constructors.Where(a => a.IsVisible);
            bool hasFieldsBeforeConstructor = visibleConstructors.Any() && Fields.Any();

            result += hasFieldsBeforeConstructor ? Util.NewLine : "";
            result += String.Join(Util.NewLine, visibleConstructors);
            bool hasMembersAfterConstructor = (visibleConstructors.Any() || Fields.Any()) && (Properties.Any() || Methods.Any());

            result += hasMembersAfterConstructor ? Util.NewLine : "";

            result += String.Join(HasPropertiesSpacing ? Util.NewLine : "", Properties);

            bool hasPropertiesAndMethods = Properties.Count > 0 && Methods.Count > 0;

            result += hasMembersAfterConstructor ? Util.NewLine : "";
            result += String.Join(Util.NewLine, Methods);

            result += NestedClasses.Count > 0 ? Util.NewLine : "";
            result += String.Join(Util.NewLine, NestedClasses);

            result += Util.NewLine + Indent + "}";
            return(result);
        }
Exemple #12
0
        <DbPropertyInfoCache, DbAttributeInfoCache, DbMethodInfoCache, DbConstructorInfoCache, DbMethodArgument> Init(
            Type type, bool anon = false)
        {
            var item = base.Init(type, anon);

            //.ToDictionary(s => s.Key);
            Propertys = new Dictionary <string, DbPropertyInfoCache>(Propertys
                                                                     .Where(f => f.Value.Attributes.All(e => !(e.Attribute is IgnoreReflectionAttribute)))
                                                                     .ToDictionary(s => s.Key, f => f.Value));
            Mehtods =
                new HashSet <DbMethodInfoCache>(
                    Mehtods.Where(f => f.Attributes.All(d => !(d.Attribute is IgnoreReflectionAttribute))));
            Constructors =
                new HashSet <DbConstructorInfoCache>(
                    Constructors.Where(f => f.Attributes.All(e => !(e.Attribute is IgnoreReflectionAttribute))));
            foreach (var dbPropertyInfoCach in Propertys)
            {
                dbPropertyInfoCach.Value.DeclaringClass = this;
            }
            foreach (var dbPropertyInfoCach in Mehtods)
            {
                dbPropertyInfoCach.DeclaringClass = this;
            }
            foreach (var dbPropertyInfoCach in Constructors)
            {
                dbPropertyInfoCach.DeclaringClass = this;
            }

            Refresh(true);
            return(item);
        }
Exemple #13
0
        public DataExportRepository(DbConnectionStringBuilder connectionString, ICatalogueRepository catalogueRepository) : base(null, connectionString)
        {
            CatalogueRepository = catalogueRepository;

            FilterManager = new DataExportFilterManager(this);

            DataExportPropertyManager = new DataExportPropertyManager(false, this);
            PackageManager            = new ExtractableDataSetPackageManager(this);

            Constructors.Add(typeof(SupplementalExtractionResults), (rep, r) => new SupplementalExtractionResults((IDataExportRepository)rep, r));
            Constructors.Add(typeof(CumulativeExtractionResults), (rep, r) => new CumulativeExtractionResults((IDataExportRepository)rep, r));
            Constructors.Add(typeof(DeployedExtractionFilter), (rep, r) => new DeployedExtractionFilter((IDataExportRepository)rep, r));
            Constructors.Add(typeof(DeployedExtractionFilterParameter), (rep, r) => new DeployedExtractionFilterParameter((IDataExportRepository)rep, r));
            Constructors.Add(typeof(ExternalCohortTable), (rep, r) => new ExternalCohortTable((IDataExportRepository)rep, r));
            Constructors.Add(typeof(ExtractableCohort), (rep, r) => new ExtractableCohort((IDataExportRepository)rep, r));
            Constructors.Add(typeof(ExtractableColumn), (rep, r) => new ExtractableColumn((IDataExportRepository)rep, r));
            Constructors.Add(typeof(ExtractableDataSet), (rep, r) => new ExtractableDataSet((IDataExportRepository)rep, r));
            Constructors.Add(typeof(ExtractionConfiguration), (rep, r) => new ExtractionConfiguration((IDataExportRepository)rep, r));
            Constructors.Add(typeof(FilterContainer), (rep, r) => new FilterContainer((IDataExportRepository)rep, r));
            Constructors.Add(typeof(GlobalExtractionFilterParameter), (rep, r) => new GlobalExtractionFilterParameter((IDataExportRepository)rep, r));
            Constructors.Add(typeof(Project), (rep, r) => new Project((IDataExportRepository)rep, r));
            Constructors.Add(typeof(SelectedDataSets), (rep, r) => new SelectedDataSets((IDataExportRepository)rep, r));
            Constructors.Add(typeof(ExtractableDataSetPackage), (rep, r) => new ExtractableDataSetPackage((IDataExportRepository)rep, r));
            Constructors.Add(typeof(ProjectCohortIdentificationConfigurationAssociation), (rep, r) => new ProjectCohortIdentificationConfigurationAssociation((IDataExportRepository)rep, r));
            Constructors.Add(typeof(SelectedDataSetsForcedJoin), (rep, r) => new SelectedDataSetsForcedJoin((IDataExportRepository)rep, r));
        }
Exemple #14
0
        public ClassInfo GenerateWrapper(string wrapperName, string baseName)
        {
            var tagClassAttribute    = Attributes.SingleOrDefault(x => x.AttributeType == typeof(TagClassAttribute));
            var hasTagClassAttribute = tagClassAttribute != null;

            if (hasTagClassAttribute)
            {
                Attributes.Remove(tagClassAttribute);
            }
            var wrapperClassInfo = new ClassInfo
            {
                AccessModifiers = AccessModifiers.Public | AccessModifiers.Partial,
                Constructors    = Constructors.Select(x => x.MakeWrapper(wrapperName)).ToList(),
                Namespace       = Namespace,
                Usings          = Usings,
                _value          = new GuerillaName(_value),
                BaseClass       = new ClassInfo(baseName)
            };

            if (hasTagClassAttribute)
            {
                wrapperClassInfo.Attributes.Add(tagClassAttribute);
            }
            wrapperClassInfo.Name = wrapperName;
            return(wrapperClassInfo);
        }
Exemple #15
0
        void AddConstructor(InterfaceGen iface, Method method, CodeGenerationOptions opt)
        {
            var ctor = new ConstructorWriter {
                Name     = iface.GetArgsName(method),
                IsPublic = true
            };

            if (method.IsEventHandlerWithHandledProperty)
            {
                ctor.Parameters.Add(new MethodParameterWriter("handled", TypeReferenceWriter.Bool));
                ctor.Body.Add("this.handled = handled;");
            }

            foreach (var p in method.Parameters)
            {
                if (p.IsSender)
                {
                    continue;
                }

                ctor.Parameters.Add(new MethodParameterWriter(p.Name, new TypeReferenceWriter(opt.GetTypeReferenceName(p))));
                ctor.Body.Add($"this.{opt.GetSafeIdentifier (p.Name)} = {opt.GetSafeIdentifier (p.Name)};");
            }

            Constructors.Add(ctor);
        }
        private Func <object[], object> CreateActivator(object[] args)
        {
            ConstructorInfo constructor = Constructors.MatchingArguments(args).FirstOrDefault();

            if (constructor == null)
            {
                throw new FastReflectionException(ObjectType, "No usable constructor found");
            }

            Type specializedType = constructor.ToSpecializedType(args);

            constructor = specializedType.GetConstructors().MatchingArguments(args).FirstOrDefault();

            if (constructor == null)
            {
                throw new FastReflectionException(specializedType,
                                                  "Specialized constructor could not be used to build the object");
            }
            ParameterExpression argsParameter = Expression.Parameter(typeof(object[]), "args");

            Expression[] parameters = constructor.GetParameters().ToArrayIndexParameters(argsParameter).ToArray();
            return
                (Expression.Lambda <Func <object[], object> >(Expression.New(constructor, parameters), argsParameter)
                 .Compile());
        }
Exemple #17
0
        T CreateFromArgs(object[] args)
        {
            if (args == null || args.Length == 0)
            {
                return(_new());
            }

            int offset = 0;
            int key    = args.Aggregate(0, (x, o) => x ^ (o == null ? offset : o.GetType().GetHashCode() << offset++));

            Func <object[], T> generator = _argGenerators.Retrieve(key, () =>
            {
                ConstructorInfo constructorInfo = Constructors
                                                  .MatchingArguments(args)
                                                  .SingleOrDefault();

                if (constructorInfo == null)
                {
                    throw new FastActivatorException(typeof(T), "No usable constructor found");
                }

                ParameterExpression argsParameter = Expression.Parameter(typeof(object[]), "args");

                Expression[] parameters = constructorInfo.GetParameters().ToArrayIndexParameters(argsParameter).ToArray();

                NewExpression newExpression = Expression.New(constructorInfo, parameters);

                Func <object[], T> lambda = Expression.Lambda <Func <object[], T> >(newExpression, argsParameter).Compile();

                return(lambda);
            });

            return(generator(args));
        }
Exemple #18
0
        /// <summary>
        ///     Writes out the type builder to a readable string
        /// </summary>
        /// <returns>Code version of the type builder</returns>
        public override string ToString()
        {
            string[] splitter  = { "." };
            string[] nameParts = Name.Split(splitter, StringSplitOptions.RemoveEmptyEntries);
            var      output    = new StringBuilder();

            output.Append("namespace ").Append(Assembly.Name);
            for (int x = 0; x < nameParts.Length - 1; ++x)
            {
                output.Append(".").Append(nameParts[x]);
            }
            output.Append("\n{\n");
            output.Append((Attributes & TypeAttributes.Public) > 0 ? "public " : "private ");
            output.Append("class ");
            output.Append(nameParts[nameParts.Length - 1]);
            string seperator = " : ";

            if (BaseClass != null)
            {
                output.Append(seperator).Append(BaseClass.Name);
                seperator = ", ";
            }
            foreach (var Interface in Interfaces)
            {
                output.Append(seperator).Append(Interface.Name);
                seperator = ", ";
            }
            output.Append("\n{");
            Constructors.ForEach(x => output.Append(x.ToString()));
            Methods.ForEach(x => output.Append(x.ToString()));
            Properties.ForEach(x => output.Append(x.GetDefinition()));
            Fields.ForEach(x => output.Append(x.GetDefinition()));
            output.Append("\n}\n}\n\n");
            return(output.ToString());
        }
Exemple #19
0
        /// <summary>
        ///     Creates a default constructor
        /// </summary>
        /// <param name="attributes">attributes for the constructor (public, private, etc.)</param>
        /// <returns>Constructor builder for the constructor</returns>
        public virtual IMethodBuilder CreateDefaultConstructor(MethodAttributes attributes = MethodAttributes.Public)
        {
            var returnValue = new DefaultConstructorBuilder(this, attributes);

            Constructors.Add(returnValue);
            return(returnValue);
        }
Exemple #20
0
        Func <object[], object> GetGenerator(int key, params object[] args)
        {
            return(_argGenerators.Retrieve(key, () =>
            {
                ConstructorInfo constructorInfo = Constructors
                                                  .MatchingArguments(args)
                                                  .SingleOrDefault();

                if (constructorInfo == null)
                {
                    throw new FastActivatorException(ObjectType, "No usable constructor found");
                }

                Type specializedType = constructorInfo.ToSpecializedType(args);

                constructorInfo = specializedType.GetConstructors().MatchingArguments(args).SingleOrDefault();

                if (constructorInfo == null)
                {
                    throw new FastActivatorException(specializedType, "Specialized constructor could not be used to build the object");
                }

                ParameterExpression argsParameter = Expression.Parameter(typeof(object[]), "args");

                Expression[] parameters = constructorInfo.GetParameters().ToArrayIndexParameters(argsParameter).ToArray();

                NewExpression newExpression = Expression.New(constructorInfo, parameters);

                Func <object[], object> lambda = Expression.Lambda <Func <object[], object> >(newExpression, argsParameter).Compile();

                return lambda;
            }));
        }
Exemple #21
0
        public MethodModel AddConstructor()
        {
            var constructor = new MethodModel(this, Name).MakePublic();

            Constructors.Add(constructor);
            return(constructor);
        }
Exemple #22
0
        public InterfaceInvokerClass(InterfaceGen iface, CodeGenerationOptions opt, CodeGeneratorContext context)
        {
            Name = $"{iface.Name}Invoker";

            IsInternal       = true;
            IsPartial        = true;
            UsePriorityOrder = true;

            Inherits = "global::Java.Lang.Object";
            Implements.Add(iface.Name);

            Attributes.Add(new RegisterAttr(iface.RawJniName, noAcw: true, additionalProperties: iface.AdditionalAttributeString())
            {
                UseGlobal = true
            });

            Fields.Add(new PeerMembersField(opt, iface.RawJniName, $"{iface.Name}Invoker", false));

            Properties.Add(new InterfaceHandleGetter());
            Properties.Add(new JniPeerMembersGetter());
            Properties.Add(new InterfaceThresholdClassGetter());
            Properties.Add(new ThresholdTypeGetter());

            Fields.Add(new FieldWriter {
                Name = "class_ref", Type = TypeReferenceWriter.IntPtr, IsShadow = opt.BuildingCoreAssembly
            });

            Methods.Add(new GetObjectMethod(iface, opt));
            Methods.Add(new ValidateMethod(iface));
            Methods.Add(new DisposeMethod());

            Constructors.Add(new InterfaceInvokerConstructor(iface, context));

            AddMemberInvokers(iface, new HashSet <string> (), opt, context);
        }
Exemple #23
0
        public void VerifyBehavior()
        {
            new CompositeIdiomaticAssertion(
                new ImplicitConversionOperatorAssertion <decimal>(_fixture),
                new ExplicitConversionMethodAssertion <decimal>(_fixture),
                new EquatableEqualsSelfAssertion(_fixture),
                new EquatableEqualsOtherAssertion(_fixture),
                new EqualityOperatorEqualsSelfAssertion(_fixture),
                new EqualityOperatorEqualsOtherAssertion(_fixture),
                new InequalityOperatorEqualsSelfAssertion(_fixture),
                new InequalityOperatorEqualsOtherAssertion(_fixture),
                new EqualsNewObjectAssertion(_fixture),
                new EqualsNullAssertion(_fixture),
                new EqualsSelfAssertion(_fixture),
                new EqualsOtherAssertion(_fixture),
                new EqualsSuccessiveAssertion(_fixture),
                new GetHashCodeSuccessiveAssertion(_fixture),
                new ComparableCompareToSelfAssertion(_fixture),
                new LessThanOperatorCompareToSelfAssertion(_fixture),
                new LessThanOrEqualOperatorCompareToSelfAssertion(_fixture),
                new GreaterThanOperatorCompareToSelfAssertion(_fixture),
                new GreaterThanOrEqualOperatorCompareToSelfAssertion(_fixture)
                ).Verify(typeof(RoadSegmentPosition));

            new GuardClauseAssertion(_fixture, new NegativeDecimalBehaviorExpectation())
            .Verify(Constructors.Select(() => new RoadSegmentPosition(0.0m)));

            new GuardClauseAssertion(_fixture, new NegativeDoubleBehaviorExpectation())
            .Verify(Methods.Select(() => RoadSegmentPosition.FromDouble(0.0)));
        }
        public override int GetHashCode()
        {
            unchecked
            {
                var hash = 17;

                hash = hash * 23 + Fields.GetHashCode();
                hash = hash * 23 + Properties.GetHashCode();
                hash = hash * 23 + Methods.GetHashCode();
                hash = hash * 23 + Constructors.GetHashCode();
                hash = hash * 23 + Gettable.GetHashCode();
                hash = hash * 23 + Settable.GetHashCode();
                hash = hash * 23 + Indexers.GetHashCode();
                hash = hash * 23 + Events.GetHashCode();

                hash = hash * 23 + Inherited.GetHashCode();
                hash = hash * 23 + Targeted.GetHashCode();
                hash = hash * 23 + NonTargeted.GetHashCode();
                hash = hash * 23 + Public.GetHashCode();
                hash = hash * 23 + NonPublic.GetHashCode();
                hash = hash * 23 + ReadOnly.GetHashCode();
                hash = hash * 23 + WriteOnly.GetHashCode();
                hash = hash * 23 + Extensions.GetHashCode();
                hash = hash * 23 + Operators.GetHashCode();
                hash = hash * 23 + Conversions.GetHashCode();
                hash = hash * 23 + Parameters.GetHashCode();
                hash = hash * 23 + Obsolete.GetHashCode();
                hash = hash * 23 + OpenConstructedGeneric.GetHashCode();
                hash = hash * 23 + TypeInitializers.GetHashCode();

                return(hash);
            }
        }
Exemple #25
0
        private void OpenConstructor(Constructors type)
        {
            ResetConstructors();
            switch (type)
            {
            case Constructors.Select:
                OpenSelectConstructor();
                break;

            case Constructors.Insert:
                OpenInsertConstructor();
                break;

            case Constructors.Update:
                OpenUpdateConstructor();
                break;

            case Constructors.Delete:
                OpenDeleteConstructor();
                break;

            case Constructors.None:
                ResetConstructors();
                break;
            }
        }
Exemple #26
0
        public void VerifyBehavior()
        {
            _fixture.Customizations.Add(
                new FiniteSequenceGenerator <int>(Enumerable.Range(0, RoadSegmentWidth.Maximum.ToInt32()).ToArray()));
            new CompositeIdiomaticAssertion(
                new ImplicitConversionOperatorAssertion <int>(_fixture),
                new ExplicitConversionMethodAssertion <int>(_fixture),
                new EquatableEqualsSelfAssertion(_fixture),
                new EquatableEqualsOtherAssertion(_fixture),
                new EqualityOperatorEqualsSelfAssertion(_fixture),
                new EqualityOperatorEqualsOtherAssertion(_fixture),
                new InequalityOperatorEqualsSelfAssertion(_fixture),
                new InequalityOperatorEqualsOtherAssertion(_fixture),
                new EqualsNewObjectAssertion(_fixture),
                new EqualsNullAssertion(_fixture),
                new EqualsSelfAssertion(_fixture),
                new EqualsOtherAssertion(_fixture),
                new EqualsSuccessiveAssertion(_fixture),
                new GetHashCodeSuccessiveAssertion(_fixture)
                ).Verify(typeof(RoadSegmentWidth));

            new GuardClauseAssertion(_fixture,
                                     new Int32RangeBehaviorExpectation(0, RoadSegmentWidth.Maximum.ToInt32(), -8, -9))
            .Verify(Constructors.Select(() => new RoadSegmentWidth(0)));
        }
Exemple #27
0
 internal static void Register(Type type)
 {
     Constructors.Add(type.GetConstructor(Type.EmptyTypes));
     Saves.Add(type, typeof(FieldBackuper <>).MakeGenericType(type)
               .GetMethod("Save"));
     Resets.Add(type, typeof(FieldBackuper <>).MakeGenericType(type)
                .GetMethod("Reset"));
 }
 public Code GetCode()
 => Class("MyProject", "My project description", "1.0.0", null, "MyTypeName",
          usingDirectiveList: UsingDirectiveLists.Create("System", "System.IO"),
          documentationCommentList: Comments.Summary("This is the class XML-doc summary comment"),
          attributeListCollection: AttributeLists.Create(Attributes.ProtoContract()),
          constructorList: ConstructorLists.Create(Constructors.Default("MyTypeName")),
          methodList: MethodLists.Create(Methods.PublicStatic("GetInt", "int", "5 + 5")),
          propertyList: PropertyLists.Create(Properties.Public("MyProperty", "string", "This is the property XML-doc summary comment", AttributeLists.Create(Attributes.ProtoMember(1)))));
Exemple #29
0
 /// <summary>
 ///   Adds constructor dependency to this <see cref="ComponentModel" />
 /// </summary>
 /// <param name="constructor"> </param>
 public void AddConstructor(ConstructorCandidate constructor)
 {
     Constructors.Add(constructor);
     foreach (var ctorDependency in constructor.Dependencies)
     {
         Dependencies.Add(ctorDependency);
     }
 }
Exemple #30
0
 /// <default>
 ///     <summary>
 ///     Sorts all members of this type.
 ///     </summary>
 /// </default>
 /// <de>
 ///     <summary>
 ///     Sortiert alle Mitglieder dieses Typen.
 ///     </summary>
 /// </de>
 public void SortMembers()
 {
     Fields.Sort();
     Constructors.Sort();
     Methods.Sort();
     Events.Sort();
     Properties.Sort();
 }
        public void Anonymous_Types_Are_Not_Supported()
        {
            Expression <Func <object> > expr = () => new { Hello = "" };

            var foundCtor = Constructors.Find(((NewExpression)expr.Body).Constructor);

            Assert.Null(foundCtor);
        }
Exemple #32
0
        public void Sealed()
        {
            // Arrange
            var subject = new Constructors(typeof(C2));
            var objBase1 = new ObjectBase(Dx.Settings);

            var values = new MockBuilder();
            ((dynamic)values).Prop = "bye";

            var objBase2 = new ObjectBase(Dx.Settings, values);

            // Act
            // Assert
            Assert.AreEqual("Hi", ((C2)subject.Construct(objBase1)).Prop);
            Assert.AreEqual("bla", ((C2)subject.Construct(objBase1, new[] { "bla" })).Prop);
            Assert.AreEqual(null, ((C2)subject.Construct(objBase1, new[] { 55 as object })).Prop);

            Assert.AreEqual("bye", ((C2)subject.Construct(objBase2)).Prop);
            Assert.AreEqual("bye", ((C2)subject.Construct(objBase2, new[] { "bla" })).Prop);
            Assert.AreEqual("bye", ((C2)subject.Construct(objBase2, new[] { 55 as object })).Prop);
        }