Ejemplo n.º 1
0
        public override void Execute()
        {
            if (!StateCommuter.Current.IsGetObject)
            {
                StateCommuter.CreateInstanceOfCurrentXamlTypeIfNotCreatedBefore();

                if (StateCommuter.Current.Instance is IMarkupExtension)
                {
                    object        val           = StateCommuter.GetValueProvidedByMarkupExtension((IMarkupExtension)StateCommuter.Current.Instance);
                    StateCommuter tempQualifier = StateCommuter;
                    tempQualifier.Current.Instance = val;

                    var collection = val as ICollection;
                    if (collection != null)
                    {
                        tempQualifier.Current.Collection = collection;
                    }
                    StateCommuter.AssociateCurrentInstanceToParent();
                }
                else if (!StateCommuter.Current.WasInstanceAssignedRightAfterBeingCreated)
                {
                    StateCommuter.AssociateCurrentInstanceToParent();
                }
            }

            Assembler.Result = StateCommuter.Current.Instance;

            StateCommuter.DecreaseLevel();
        }
Ejemplo n.º 2
0
        public override void Execute()
        {
            if (!StateCommuter.Current.IsGetObject)
            {
                StateCommuter.CreateInstanceOfCurrentXamlTypeIfNotCreatedBefore();
                StateCommuter.PutNameToCurrentInstanceIfAny();

                var instance = StateCommuter.Current.Instance;

                if (instance is IMarkupExtension)
                {
                    ProcessCurrentInstanceValueWithMarkupExtension();
                }
                else if (!StateCommuter.WasAssociatedRightAfterCreation)
                {
                    StateCommuter.AssociateCurrentInstanceToParent();
                }

                StateCommuter.RegisterInstanceNameToNamescope();
                lifyCycleListener.OnAfterProperties(instance);
                lifyCycleListener.OnEnd(instance);
            }

            setResult(StateCommuter);

            StateCommuter.DecreaseLevel();
        }
Ejemplo n.º 3
0
 private void CreateInstanceOfCurrentTypeAndAssociateIfPossible()
 {
     StateCommuter.CreateInstanceOfCurrentXamlTypeIfNotCreatedBefore();
     if (!StateCommuter.WasAssociatedRightAfterCreation)
     {
         StateCommuter.AssociateCurrentInstanceToParentForCreation();
     }
 }
Ejemplo n.º 4
0
        private void AccommodateLevelsForIncomingChildren()
        {
            StateCommuter.CreateInstanceOfCurrentXamlTypeIfNotCreatedBefore();
            var instance = StateCommuter.Current.Instance;

            var collection = instance as ICollection;

            if (collection != null)
            {
                StateCommuter.Current.Collection = collection;
            }
        }
Ejemplo n.º 5
0
        public override void Execute()
        {
            if (StateCommuter.ValueProcessingMode == ValueProcessingMode.ConstructionParameter)
            {
                AdaptCurrentCtorArgumentsToCurrentType();
                StateCommuter.ValueProcessingMode = ValueProcessingMode.AssignToMember;
            }

            if (IsTherePendingInstanceWaitingToBeAssigned)
            {
                StateCommuter.AssociateCurrentInstanceToParent();
                StateCommuter.DecreaseLevel();
            }
        }
Ejemplo n.º 6
0
        private void ProcessCurrentInstanceValueWithMarkupExtension()
        {
            var processedValue = StateCommuter.GetValueProvidedByMarkupExtension((IMarkupExtension)StateCommuter.Current.Instance);

            StateCommuter.Current.Instance = processedValue;

            var collection = processedValue as ICollection;

            if (collection != null)
            {
                StateCommuter.Current.Collection = collection;
            }

            StateCommuter.AssociateCurrentInstanceToParent();
        }
Ejemplo n.º 7
0
        public override void Execute()
        {
            if (StateCommuter.Level == 0)
            {
                throw new ParseException("An object cannot start after level zero has been reached. This condition may indicate that there are more than one object at the Root Level. Please, verify that there is ONLY one root object.");
            }

            if (ConflictsWithObjectBeingConfigured)
            {
                StateCommuter.RaiseLevel();
            }

            StateCommuter.Current.XamlType = xamlType;
            OverrideInstanceAndTypeInLevel1();
        }
Ejemplo n.º 8
0
        private void OverrideInstanceAndTypeInLevel1()
        {
            if (StateCommuter.Level == 1 && rootInstance != null)
            {
                StateCommuter tempQualifier = StateCommuter;
                tempQualifier.Current.Instance = rootInstance;

                var collection = rootInstance as ICollection;
                if (collection != null)
                {
                    tempQualifier.Current.Collection = collection;
                }
                var typeContext        = Assembler.WiringContext.TypeContext;
                var xamlTypeOfInstance = typeContext.GetXamlType(rootInstance.GetType());
                StateCommuter.Current.XamlType = xamlTypeOfInstance;
            }
        }
Ejemplo n.º 9
0
        private void OverrideInstanceAndTypeInLevel1()
        {
            if (StateCommuter.Level == 1 && rootInstance != null)
            {
                StateCommuter tempQualifier = StateCommuter;
                tempQualifier.Current.Instance = rootInstance;

                var collection = rootInstance as ICollection;
                if (collection != null)
                {
                    tempQualifier.Current.Collection = collection;
                }

                var xamlTypeOfInstance = typeRepository.GetByType(rootInstance.GetType());
                StateCommuter.Current.XamlType = xamlTypeOfInstance;
            }
        }
Ejemplo n.º 10
0
        public override void Execute()
        {
            var previousMember = StateCommuter.Current.XamlMember;

            StateCommuter.RaiseLevel();
            StateCommuter.Current.IsGetObject = true;
            var instanceToGet = StateCommuter.ValueOfPreviousInstanceAndItsMember;

            StateCommuter.Current.Instance   = instanceToGet;
            StateCommuter.Current.XamlMember = previousMember;

            var collection = instanceToGet as ICollection;

            if (collection != null)
            {
                StateCommuter.Current.Collection = collection;
            }
        }
Ejemplo n.º 11
0
        public override void Execute()
        {
            switch (StateCommuter.ValueProcessingMode)
            {
            case ValueProcessingMode.InitializationValue:
                object compatibleValue;
                CommonValueConversion.TryConvert(value, StateCommuter.Current.XamlType, valueContext, out compatibleValue);
                StateCommuter.Current.Instance    = compatibleValue;
                StateCommuter.ValueProcessingMode = ValueProcessingMode.AssignToMember;
                break;

            case ValueProcessingMode.Key:
                StateCommuter.SetKey(value);
                StateCommuter.ValueProcessingMode = ValueProcessingMode.AssignToMember;
                break;

            case ValueProcessingMode.ConstructionParameter:
                StateCommuter.AddCtorArgument(value);
                break;

            case ValueProcessingMode.AssignToMember:
                StateCommuter.RaiseLevel();
                StateCommuter.Current.Instance = value;
                StateCommuter.AssociateCurrentInstanceToParent();
                StateCommuter.DecreaseLevel();
                break;

            case ValueProcessingMode.Name:
                StateCommuter.SetNameForCurrentInstance(value);
                StateCommuter.ValueProcessingMode = ValueProcessingMode.AssignToMember;
                break;

            default:
                throw new ParseException(
                          "Unexpected mode was set trying to process a Value XAML instruction. " +
                          $"We found \"{StateCommuter.ValueProcessingMode}\") and it cannot be handled.");
            }
        }
Ejemplo n.º 12
0
        public override void Execute()
        {
            switch (StateCommuter.ValueProcessingMode)
            {
            case ValueProcessingMode.InitializationValue:
                StateCommuter.Current.Instance = ValuePipeLine.ConvertValueIfNecessary(value, StateCommuter.Current.XamlType);

                break;

            case ValueProcessingMode.Key:
                StateCommuter.SetKey(value);
                StateCommuter.ValueProcessingMode = ValueProcessingMode.AssignToMember;
                break;

            case ValueProcessingMode.ConstructionParameter:
                StateCommuter.AddCtorArgument(value);
                break;

            case ValueProcessingMode.AssignToMember:
                StateCommuter.RaiseLevel();
                StateCommuter.Current.Instance = value;
                StateCommuter.AssignChildToParentProperty();
                StateCommuter.DecreaseLevel();
                break;

            case ValueProcessingMode.Name:
                StateCommuter.SetNameForCurrentInstance(value);
                StateCommuter.ValueProcessingMode = ValueProcessingMode.AssignToMember;
                break;

            default:
                throw new XamlParseException(
                          "Unexpected mode was set trying to process a Value XAML instruction. " +
                          $"We found \"{StateCommuter.ValueProcessingMode}\") and it cannot be handled.");
            }
        }
Ejemplo n.º 13
0
 public StartMemberCommand(StateCommuter stateCommuter, MemberBase member)
     : base(stateCommuter)
 {
     this.member = member;
 }
Ejemplo n.º 14
0
 public GetObjectCommand(StateCommuter stateCommuter) : base(stateCommuter)
 {
 }
Ejemplo n.º 15
0
 public EndObjectCommand(StateCommuter stateCommuter, Action<StateCommuter> setResult, IInstanceLifeCycleListener lifyCycleListener)
     : base(stateCommuter)
 {
     this.setResult = setResult;
     this.lifyCycleListener = lifyCycleListener;
 }
Ejemplo n.º 16
0
 protected Command(StateCommuter stateCommuter)
 {
     StateCommuter = stateCommuter;
 }
 public NamespaceDeclarationCommand(NamespaceDeclaration namespaceDeclaration, StateCommuter stateCommuter) : base(stateCommuter)
 {
     this.namespaceDeclaration = namespaceDeclaration;
 }
Ejemplo n.º 18
0
 public ValueCommand(StateCommuter stateCommuter, IValueContext valueContext, string value) : base(stateCommuter)
 {
     this.valueContext = valueContext;
     this.value        = value;
 }
Ejemplo n.º 19
0
 private void ForceInstanceCreationOfCurrentType()
 {
     StateCommuter.CreateInstanceOfCurrentXamlTypeIfNotCreatedBefore();
 }
Ejemplo n.º 20
0
 public GetObjectCommand(StateCommuter stateCommuter) : base(stateCommuter)
 {            
 }
Ejemplo n.º 21
0
 public StartObjectCommand(StateCommuter stateCommuter, ITypeRepository typeRepository, XamlType xamlType, object rootInstance) : base(stateCommuter)
 {
     this.typeRepository = typeRepository;
     this.xamlType = xamlType;
     this.rootInstance = rootInstance;
 }
Ejemplo n.º 22
0
 public ValueCommand(StateCommuter stateCommuter, IValueContext valueContext, string value)
     : base(stateCommuter)
 {
     this.valueContext = valueContext;
     this.value = value;
 }
Ejemplo n.º 23
0
 public EndObjectCommand(StateCommuter stateCommuter, Action <StateCommuter> setResult, IInstanceLifeCycleListener lifyCycleListener) : base(stateCommuter)
 {
     this.setResult         = setResult;
     this.lifyCycleListener = lifyCycleListener;
 }
Ejemplo n.º 24
0
 public ValueCommand(StateCommuter stateCommuter, ITypeRepository typeSource, ITopDownValueContext topDownValueContext, string value) : base(stateCommuter)
 {
     this.value = value;
     ValuePipeLine = new ValuePipeline(typeSource, topDownValueContext);
 }
Ejemplo n.º 25
0
 public EndMemberCommand(ITypeRepository typeRepository, StateCommuter stateCommuter, IValueContext valueContext) : base(stateCommuter)
 {
     this.typeRepository = typeRepository;
     this.valueContext   = valueContext;
 }
Ejemplo n.º 26
0
 public EndMemberCommand(ITypeRepository typeRepository, StateCommuter stateCommuter, IValueContext valueContext)
     : base(stateCommuter)
 {
     this.typeRepository = typeRepository;
     this.valueContext = valueContext;
 }
Ejemplo n.º 27
0
 protected Command(StateCommuter stateCommuter)
 {
     StateCommuter = stateCommuter;
 }
Ejemplo n.º 28
0
 public EndMemberCommand(ITypeRepository typeRepository, StateCommuter stateCommuter) : base(stateCommuter)
 {
     this.typeRepository = typeRepository;
 }
Ejemplo n.º 29
0
 public StartObjectCommand(StateCommuter stateCommuter, ITypeRepository typeRepository, XamlType xamlType, object rootInstance) : base(stateCommuter)
 {
     this.typeRepository = typeRepository;
     this.xamlType       = xamlType;
     this.rootInstance   = rootInstance;
 }
Ejemplo n.º 30
0
 public EndObjectCommand(StateCommuter stateCommuter, Action<StateCommuter> setResult) : base(stateCommuter)
 {
     this.setResult = setResult;
 }
Ejemplo n.º 31
0
 public StartMemberCommand(StateCommuter stateCommuter, MemberBase member) : base(stateCommuter)
 {
     this.member = member;
 }
 public NamespaceDeclarationCommand(NamespaceDeclaration namespaceDeclaration, StateCommuter stateCommuter) : base(stateCommuter)
 {
     this.namespaceDeclaration = namespaceDeclaration;
 }