コード例 #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();
        }
コード例 #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();
        }
コード例 #3
0
 private void CreateInstanceOfCurrentTypeAndAssociateIfPossible()
 {
     StateCommuter.CreateInstanceOfCurrentXamlTypeIfNotCreatedBefore();
     if (!StateCommuter.WasAssociatedRightAfterCreation)
     {
         StateCommuter.AssociateCurrentInstanceToParentForCreation();
     }
 }
コード例 #4
0
        private void AccommodateLevelsForIncomingChildren()
        {
            StateCommuter.CreateInstanceOfCurrentXamlTypeIfNotCreatedBefore();
            var instance = StateCommuter.Current.Instance;

            var collection = instance as ICollection;

            if (collection != null)
            {
                StateCommuter.Current.Collection = collection;
            }
        }
コード例 #5
0
        public override void Execute()
        {
            if (StateCommuter.ValueProcessingMode == ValueProcessingMode.ConstructionParameter)
            {
                AdaptCurrentCtorArgumentsToCurrentType();
                StateCommuter.ValueProcessingMode = ValueProcessingMode.AssignToMember;
            }

            if (IsTherePendingInstanceWaitingToBeAssigned)
            {
                StateCommuter.AssociateCurrentInstanceToParent();
                StateCommuter.DecreaseLevel();
            }
        }
コード例 #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();
        }
コード例 #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();
        }
コード例 #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;
            }
        }
コード例 #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;
            }
        }
コード例 #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;
            }
        }
コード例 #11
0
ファイル: ValueCommand.cs プロジェクト: nagyistge/OmniXAML
        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.");
            }
        }
コード例 #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.");
            }
        }
コード例 #13
0
 public StartMemberCommand(StateCommuter stateCommuter, MemberBase member)
     : base(stateCommuter)
 {
     this.member = member;
 }
コード例 #14
0
 public GetObjectCommand(StateCommuter stateCommuter) : base(stateCommuter)
 {
 }
コード例 #15
0
 public EndObjectCommand(StateCommuter stateCommuter, Action<StateCommuter> setResult, IInstanceLifeCycleListener lifyCycleListener)
     : base(stateCommuter)
 {
     this.setResult = setResult;
     this.lifyCycleListener = lifyCycleListener;
 }
コード例 #16
0
ファイル: Command.cs プロジェクト: modulexcite/OmniXAML
 protected Command(StateCommuter stateCommuter)
 {
     StateCommuter = stateCommuter;
 }
コード例 #17
0
 public NamespaceDeclarationCommand(NamespaceDeclaration namespaceDeclaration, StateCommuter stateCommuter) : base(stateCommuter)
 {
     this.namespaceDeclaration = namespaceDeclaration;
 }
コード例 #18
0
ファイル: ValueCommand.cs プロジェクト: nagyistge/OmniXAML
 public ValueCommand(StateCommuter stateCommuter, IValueContext valueContext, string value) : base(stateCommuter)
 {
     this.valueContext = valueContext;
     this.value        = value;
 }
コード例 #19
0
 private void ForceInstanceCreationOfCurrentType()
 {
     StateCommuter.CreateInstanceOfCurrentXamlTypeIfNotCreatedBefore();
 }
コード例 #20
0
 public GetObjectCommand(StateCommuter stateCommuter) : base(stateCommuter)
 {            
 }
コード例 #21
0
 public StartObjectCommand(StateCommuter stateCommuter, ITypeRepository typeRepository, XamlType xamlType, object rootInstance) : base(stateCommuter)
 {
     this.typeRepository = typeRepository;
     this.xamlType = xamlType;
     this.rootInstance = rootInstance;
 }
コード例 #22
0
ファイル: ValueCommand.cs プロジェクト: AvaloniaUI/OmniXAML
 public ValueCommand(StateCommuter stateCommuter, IValueContext valueContext, string value)
     : base(stateCommuter)
 {
     this.valueContext = valueContext;
     this.value = value;
 }
コード例 #23
0
 public EndObjectCommand(StateCommuter stateCommuter, Action <StateCommuter> setResult, IInstanceLifeCycleListener lifyCycleListener) : base(stateCommuter)
 {
     this.setResult         = setResult;
     this.lifyCycleListener = lifyCycleListener;
 }
コード例 #24
0
ファイル: ValueCommand.cs プロジェクト: modulexcite/OmniXAML
 public ValueCommand(StateCommuter stateCommuter, ITypeRepository typeSource, ITopDownValueContext topDownValueContext, string value) : base(stateCommuter)
 {
     this.value = value;
     ValuePipeLine = new ValuePipeline(typeSource, topDownValueContext);
 }
コード例 #25
0
 public EndMemberCommand(ITypeRepository typeRepository, StateCommuter stateCommuter, IValueContext valueContext) : base(stateCommuter)
 {
     this.typeRepository = typeRepository;
     this.valueContext   = valueContext;
 }
コード例 #26
0
 public EndMemberCommand(ITypeRepository typeRepository, StateCommuter stateCommuter, IValueContext valueContext)
     : base(stateCommuter)
 {
     this.typeRepository = typeRepository;
     this.valueContext = valueContext;
 }
コード例 #27
0
ファイル: Command.cs プロジェクト: nagyistge/OmniXAML
 protected Command(StateCommuter stateCommuter)
 {
     StateCommuter = stateCommuter;
 }
コード例 #28
0
 public EndMemberCommand(ITypeRepository typeRepository, StateCommuter stateCommuter) : base(stateCommuter)
 {
     this.typeRepository = typeRepository;
 }
コード例 #29
0
 public StartObjectCommand(StateCommuter stateCommuter, ITypeRepository typeRepository, XamlType xamlType, object rootInstance) : base(stateCommuter)
 {
     this.typeRepository = typeRepository;
     this.xamlType       = xamlType;
     this.rootInstance   = rootInstance;
 }
コード例 #30
0
 public EndObjectCommand(StateCommuter stateCommuter, Action<StateCommuter> setResult) : base(stateCommuter)
 {
     this.setResult = setResult;
 }
コード例 #31
0
 public StartMemberCommand(StateCommuter stateCommuter, MemberBase member) : base(stateCommuter)
 {
     this.member = member;
 }
コード例 #32
0
 public NamespaceDeclarationCommand(NamespaceDeclaration namespaceDeclaration, StateCommuter stateCommuter) : base(stateCommuter)
 {
     this.namespaceDeclaration = namespaceDeclaration;
 }