public override void OnBeforeBuild(BuilderState state)
        {
            if (this._config == null)
            {
                this._config = state.ResolveOption(this.option);
            }

            if (this._config == null)
            {
                return;
            }

            if (this._config.packages.Count > 0)
            {
                foreach (var p in this._config.packages)
                {
                    if (!state.includedPackages.Contains(p))
                    {
                        state.includedPackages.Add(p);
                    }
                }
            }

            for (int i = 0; i < this._config.modules.Count; i++)
            {
                var m = this._config.modules[i];
                m.OnBeforeBuild(state);
            }
        }
Esempio n. 2
0
        public void AppendLineWithText_Adds_Text()
        {
            var sut = new BuilderState(new TypeInformation());

            sut.AppendLine("hello");
            Assert.Equal($"hello{Environment.NewLine}", sut.Builder.ToString());
        }
 public static XElement Build(IXmlDescriptor descriptor, BuilderState state = null)
 {
     if (state == null) state = new BuilderState();
     descriptor = ProcessBindings(descriptor, state);
     var xelement = new XElement(descriptor.XmlTagName);
     if (descriptor.XmlAttributes != null)
         foreach (var attribute in descriptor.XmlAttributes)
         {
             if (attribute.Key != null && !attribute.Value.IsDefault())
             {
                 var xattribute = new XAttribute(attribute.Key, attribute.Value);
                 xelement.Add(xattribute);
             }
         }
     if (descriptor.XmlChildren != null)
         foreach (var child in descriptor.XmlChildren)
             if (child != null)
             {
                 var xchild = Build(child, state);
                 xelement.Add(xchild);
             }
     if (descriptor.XmlCustomContent != null)
         xelement.Add(descriptor.XmlCustomContent);
     return xelement;
 }
Esempio n. 4
0
        public void AppendLine_Adds_EmptyLine()
        {
            var sut = new BuilderState(new TypeInformation());

            sut.AppendLine();
            Assert.Equal(Environment.NewLine, sut.Builder.ToString());
        }
 private static IXmlDescriptor ProcessBindings(IXmlDescriptor descriptor, BuilderState state)
 {
     var bindable = descriptor as IBindable;
     if (bindable != null && bindable.DataContext != null)
     {
         var data = bindable.DataContext;
         var bindableType = bindable.GetType();
         var bindableProps = state.GetTypeProps(bindableType);
         var bindablePropValues = bindableProps
             .Select(b => new { Property = b, Value = b.IsIndexed() ? null : b.GetValue(bindable)?.ToString() })
             .Where(b => b.Value.IsBindingDefenition());
         if (bindablePropValues.Any())
         {
             var dataType = data.GetType();
             var dataProps = state.GetTypeProps(dataType);
             var correspondingProperties = bindablePropValues
                 .Select(b => new { BindablePropery = b.Property, DataProperty = dataProps.FirstOrDefault(d => d.Name.ToBindingDefenition() == b.Value && d.PropertyType == b.Property.PropertyType) })
                 .Where(p => p.DataProperty != null).ToList();
             foreach (var pair in correspondingProperties)
             {
                 var value = pair.DataProperty.GetValue(data);
                 pair.BindablePropery.SetValue(bindable, value);
             }
         }
     }            
     return descriptor;
 }
Esempio n. 6
0
        public ITreeBuilder End()
        {
            ++noOfCommands;

            if (RequiresRootNode())
            {
                SetErrorCode(BuilderError.REQUIRES_A_ROOT_NODE);
                return(this);
            }

            if (IsTreeInvalid())
            {
                return(this);
            }

            if (mCallStack.Count <= 0)
            {
                SetErrorCode(BuilderError.STACK_UNDERFLOW);
                return(this);
            }

            mCallStack.Pop();

            if (!ContainsItems())
            {
                State      = BuilderState.TREE_OK;
                mErrorCode = BuilderError.NO_ERROR;
            }
            //delete frame;
            return(this);
        }
Esempio n. 7
0
 private void PushNewFrame(INode currentNode)
 {
     mCallStack.Push(new TreeBuilderFrame {
         Parent = currentNode
     });
     State = BuilderState.INVALID_TREE;
 }
Esempio n. 8
0
        void RunTransformsAndGenerateCode(ref BuilderState state, IDecompilerOutput output, DecompilationContext ctx, IAstTransform?additionalTransform = null)
        {
            var astBuilder = state.AstBuilder;

            astBuilder.RunTransformations(transformAbortCondition);
            if (additionalTransform is not null)
            {
                additionalTransform.Run(astBuilder.SyntaxTree);
            }
            var settings = GetDecompilerSettings();

            CSharpDecompiler.AddXmlDocumentation(ref state, settings, astBuilder);
            var csharpUnit = astBuilder.SyntaxTree;

            csharpUnit.AcceptVisitor(new ICSharpCode.NRefactory.CSharp.InsertParenthesesVisitor()
            {
                InsertParenthesesForReadability = true
            });
            GenericGrammarAmbiguityVisitor.ResolveAmbiguities(csharpUnit);
            var unit             = csharpUnit.AcceptVisitor(new CSharpToVBConverterVisitor(state.AstBuilder.Context.CurrentModule, new ILSpyEnvironmentProvider(state.State.XmlDoc_StringBuilder)), null);
            var outputFormatter  = new VBTextOutputFormatter(output, astBuilder.Context);
            var formattingPolicy = CreateVBFormattingOptions(settings);

            unit.AcceptVisitor(new OutputVisitor(outputFormatter, formattingPolicy), null);
        }
 void Awake()
 {
     stopwatch             = new Stopwatch();
     state                 = BuilderState.None;
     startQualifierThread  = false;
     regionLocationIndexes = new List <int>();
 }
Esempio n. 10
0
        public void DoubleIncrement_Adds_DoubleIdentation()
        {
            var sut = new BuilderState(new TypeInformation()).IncrementIdentation().IncrementIdentation();

            sut.AppendLine("hello");
            Assert.Equal($"        hello{Environment.NewLine}", sut.Builder.ToString());
        }
Esempio n. 11
0
        public override void OnBuild(BuilderState config)
        {
            var targetGroup      = BuilderWindow.GetBuildTargetGroup(config.buildTarget);
            var scriptingDefines = PlayerSettings.GetScriptingDefineSymbolsForGroup(targetGroup);

            config.parameters[this] = new State
            {
                targetGroup     = targetGroup,
                originalDefines = scriptingDefines
            };

            var newDefines = new List <string>();

            foreach (var d in scriptingDefines.Split(';').Select(x => x.Trim()).Where(x => !string.IsNullOrEmpty(x)))
            {
                if (!newDefines.Contains(d))
                {
                    newDefines.Add(d);
                }
            }

            foreach (var s in this.defines)
            {
                if (!newDefines.Contains(s))
                {
                    newDefines.Add(s);
                }
            }

            PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, string.Join(";", newDefines.ToArray()));
        }
Esempio n. 12
0
 public DLCTransactionBuilder GetBuilder(Network network)
 {
     if (BuilderState is null)
     {
         throw new InvalidOperationException("The builder is not created yet");
     }
     return(new DLCTransactionBuilder(BuilderState.ToString(), network));
 }
 internal TypeBuilder(ManualCompositeTypeProvider provider, Expression <Func <T, int> > versionGetter, string typeName = null)
 {
     State          = new BuilderState();
     State.Provider = provider;
     State.Type     = typeof(T);
     State.TypeName = typeName ?? typeof(T).FullName;
     SetVersionProperty(versionGetter);
 }
Esempio n. 14
0
 public TreeBuilder()
 {
     mCallStack   = new Stack <TreeBuilderFrame> ();
     noOfCommands = 0;
     mErrorCode   = BuilderError.NO_ERROR;
     State        = BuilderState.INVALID_TREE;
     mRoot        = null;
 }
Esempio n. 15
0
        public void Increment_Increases_Identation()
        {
            var sut   = new BuilderState(new TypeInformation());
            var state = sut.IncrementIdentation();

            Assert.Equal(0, sut.Identation);
            Assert.Equal(4, state.Identation);
        }
Esempio n. 16
0
        public void AppendLineWithText_Adds_IdentationSpacesAndText()
        {
            var baseIdentation = new BuilderState(new TypeInformation());
            var sut            = baseIdentation.IncrementIdentation();

            sut.AppendLine("world");
            Assert.Equal($"    world{Environment.NewLine}", sut.Builder.ToString());
        }
Esempio n. 17
0
		public TreeBuilder ()
		{
			mCallStack = new Stack<TreeBuilderFrame> ();
			noOfCommands = 0;
			mErrorCode = BuilderError.NO_ERROR;
			State = BuilderState.INVALID_TREE;
			mRoot = null;
		}
Esempio n. 18
0
 private void Push(BuilderState state)
 {
     if (state == BuilderState.Array || state == BuilderState.Struct)
     {
         _firstObjectItemWritten.Add(false);
     }
     _state.Push(state);
 }
 public void AdvanceTo(BuilderState next)
 {
     if(!CanAdvanceTo(next))
         throw new InvalidOperationException("Can't move from state " + _state.ToString() + " to state " + next.ToString() + ".");
     BuilderState before = _state;
     _state = next;
     OnAfterAdvance(before, next, before != BuilderState.Idle, before != BuilderState.Idle && before != BuilderState.System);
 }
            public FeatureImportInfo(BuilderState state, FeatureImportType type, uint script, uint language, uint feature)
            {
                _state = state;

                _type     = type;
                _script   = script;
                _language = language;
                _feature  = feature;
            }
Esempio n. 21
0
        private void classAnalysis(TypeDefinition classDef)
        {
            BuilderState state = new BuilderState(this);

            foreach (var pass in classAnalysisPasses)
            {
                pass.analyze(classDef, state);
            }
        }
Esempio n. 22
0
        private void instructionAnalysis(Instruction instruction)
        {
            BuilderState state = new BuilderState(this);

            foreach (var pass in instructionAnalysisPasses)
            {
                pass.analyze(instruction, state);
            }
        }
Esempio n. 23
0
        public void Increment_DoesNotChange_TypeInformation_Builder_ToProcessTypeSymbols()
        {
            var sut   = new BuilderState(new TypeInformation());
            var state = sut.IncrementIdentation();

            Assert.Same(sut.Builder, state.Builder);
            Assert.Same(sut.TypeInfo, state.TypeInfo);
            Assert.Same(sut.ToProcessTypeSymbols, state.ToProcessTypeSymbols);
        }
Esempio n. 24
0
        public void BeginProperty(string name)
        {
            Log("Begin property named " + name);

            Debug.Assert(m_BuilderState == BuilderState.Rule);
            m_BuilderState = BuilderState.Property;

            m_CurrentPropertyName = name;
        }
Esempio n. 25
0
        private void methodAnalysis(MethodDefinition methodDef)
        {
            BuilderState state = new BuilderState(this);

            foreach (var pass in methodAnalysisPasses)
            {
                pass.analyze(methodDef, state);
            }
        }
Esempio n. 26
0
        private void fieldAnalysis(FieldDefinition fieldDef)
        {
            BuilderState state = new BuilderState(this);

            foreach (var pass in fieldAnalysisPasses)
            {
                pass.analyze(fieldDef, state);
            }
        }
 internal VersionBuilder(ManualCompositeTypeProvider provider, int version, CompositeProperty versionProperty, string typeName = null)
 {
     State                 = new BuilderState();
     State.Provider        = provider;
     State.Type            = typeof(T);
     State.TypeName        = typeName ?? typeof(T).FullName;
     State.Version         = version;
     State.VersionProperty = versionProperty;
 }
Esempio n. 28
0
        public override void OnAfterBuild(BuilderState config)
        {
            if (!this.runAfterBuild || string.IsNullOrEmpty(this.path))
            {
                return;
            }

            this.Run(this.path, config);
        }
Esempio n. 29
0
        public void NewBuilder_Initialized()
        {
            var typeInfo = new TypeInformation();
            var sut      = new BuilderState(typeInfo);

            Assert.Same(typeInfo, sut.TypeInfo);
            Assert.Equal(0, sut.Identation);
            Assert.Empty(sut.ToProcessTypeSymbols);
            Assert.NotNull(sut.Builder);
        }
        public bool CanAdvanceTo(BuilderState next)
        {
            if(next == BuilderState.Idle)
                return true;

            int n = (int)next;
            int s = (int)_state;

            return n >= s;
        }
Esempio n. 31
0
        public void BeginRule(int ruleLine)
        {
            Log("Beginning rule");
            Debug.Assert(m_BuilderState == BuilderState.Init);
            m_BuilderState = BuilderState.Rule;

            m_CurrentRule = new StyleRule {
                line = ruleLine
            };
        }
Esempio n. 32
0
    private void defineQualifiers()
    {
        WorldBuilderProtocol.defineQualifiers(ref worldData);

        worldData.updateBoxerDistribution();

        state = BuilderState.Complete;

        stopwatch.Stop();
        print(stopwatch.Elapsed);
    }
        public void AdvanceTo(BuilderState next)
        {
            if (!CanAdvanceTo(next))
            {
                throw new InvalidOperationException("Can't move from state " + _state.ToString() + " to state " + next.ToString() + ".");
            }
            BuilderState before = _state;

            _state = next;
            OnAfterAdvance(before, next, before != BuilderState.Idle, before != BuilderState.Idle && before != BuilderState.System);
        }
        public void EndProperty()
        {
            Log("Ending property");

            Debug.Assert(m_BuilderState == BuilderState.Property);
            m_BuilderState = BuilderState.Rule;

            m_CurrentProperty.values = m_CurrentValues.ToArray();
            m_CurrentProperty        = null;
            m_CurrentValues.Clear();
        }
Esempio n. 35
0
        public void Builder_AppendsLine_BasedOnItsIdentation()
        {
            var baseIdentation = new BuilderState(new TypeInformation());

            baseIdentation.AppendLine("hello");
            var sut = baseIdentation.IncrementIdentation();

            sut.AppendLine("world");
            baseIdentation.AppendLine("!");
            Assert.Equal($"hello{Environment.NewLine}    world{Environment.NewLine}!{Environment.NewLine}", sut.Builder.ToString());
        }
Esempio n. 36
0
 protected override void OnAfterAdvance(BuilderState before, BuilderState after, bool wasInsideSystem, bool wasInsideGroup)
 {
     if(after != before)
     {
         if(wasInsideGroup)
             _writer.WriteEndElement();
         if(after == BuilderState.Idle)
             _writer.WriteEndElement();
         else
             _writer.WriteStartElement(after.ToString(), Context.YttriumNamespace);
     }
 }
Esempio n. 37
0
        private BuilderState Pop(BuilderState expectedState)
        {
            var currentState = Peek();
            if (currentState != expectedState)
            {
                throw new InvalidOperationException(string.Format("Invalid state: current state is {0} but {1} was expected.", currentState, expectedState));
            }

            var lastState = _state.Pop();

            if (lastState == BuilderState.Array || lastState == BuilderState.Struct)
            {
                _firstObjectItemWritten.RemoveAt(_firstObjectItemWritten.Count - 1);
            }

            return lastState;
        }
Esempio n. 38
0
 public void SetFrom(IDataReader reader)
 {
     Id = reader.GetInt("Id").Value;
      State = (BuilderState) reader.GetInt("StateId").Value;
 }
 public void UpdateState(BuilderState state)
 {
     Builder.State = state;
       dbBuilder.UpdateState(Builder.Id, state);
 }
Esempio n. 40
0
		private void PushNewFrame (INode currentNode)
		{
			mCallStack.Push (new TreeBuilderFrame { Parent=currentNode });
			State = BuilderState.INVALID_TREE;
		}
Esempio n. 41
0
		public ITreeBuilder End()
		{
			++noOfCommands;

			if (RequiresRootNode())
			{
				SetErrorCode(BuilderError.REQUIRES_A_ROOT_NODE);
				return this;
			}

			if(IsTreeInvalid())
			{
				return this;
			}

			if(mCallStack.Count <= 0)
			{
				SetErrorCode (BuilderError.STACK_UNDERFLOW);
				return this;
			}

			mCallStack.Pop();

			if(!ContainsItems())
			{
				State = BuilderState.TREE_OK;
				mErrorCode = BuilderError.NO_ERROR;
			}
			//delete frame;
			return this;
		}
 public BuilderStateMachine()
 {
     _state = BuilderState.Idle;
 }
 public virtual void Reset()
 {
     _state = BuilderState.Idle;
 }
 protected virtual void OnAfterAdvance(BuilderState before, BuilderState after, bool wasInsideSystem, bool wasInsideGroup)
 {
 }
Esempio n. 45
0
        public void UpdateState(int builderId, BuilderState state)
        {
            const string query = "UPDATE [Builder] SET [StateId] = {1} WHERE Id = {0}";

             using (var connection = SqlConnectionHelper.OpenConnection(connectionString))
             {
            using (var cmd = new SqlCommand(string.Format(query, builderId, (int)state), connection))
            {
               cmd.CommandTimeout = 30000;
               cmd.ExecuteNonQuery();
            }
             }
        }
Esempio n. 46
0
 private void Push(BuilderState state)
 {
     if (state == BuilderState.Array || state == BuilderState.Struct)
     {
         _firstObjectItemWritten.Add(false);
     }
     _state.Push(state);
 }