Esempio n. 1
0
        public void UseConstantForBaseCtor(Variable variable)
        {
            var index = BaseConstructorArguments.GetFirstIndex(v => v.VariableType == variable.VariableType);

            if (index < 0)
            {
                throw new InvalidOperationException("No base constructor arguments of type " + variable.VariableType.FullNameInCode());
            }

            BaseConstructorArguments[index] = variable;
            AllInjectedFields.RemoveAt(index);
        }
Esempio n. 2
0
        private void writeConstructorMethod(ISourceWriter writer, IList<InjectedField> args)
        {
            var ctorArgs = args.Select(x => x.CtorArgDeclaration).Join(", ");
            var declaration = $"BLOCK:public {TypeName}({ctorArgs})";
            if (BaseConstructorArguments.Any())
                declaration = $"{declaration} : base({BaseConstructorArguments.Select(x => x.CtorArg).Join(", ")})";

            writer.Write(declaration);

            foreach (var field in args) field.WriteAssignment(writer);

            writer.FinishBlock();
        }
Esempio n. 3
0
 Variable IVariableSource.Create(Type type)
 {
     return(BaseConstructorArguments.FirstOrDefault(x => x.ArgType == type));
 }
Esempio n. 4
0
 bool IVariableSource.Matches(Type type)
 {
     return(BaseConstructorArguments.Any(x => x.ArgType == type));
 }