public override object Visit(AST.UsingAliasDeclaration usingAliasDeclaration, object data)
 {
     Using u = new Using();
     u.Aliases[usingAliasDeclaration.Alias] = usingAliasDeclaration.Namespace;
     cu.Usings.Add(u);
     return data;
 }
 public override object Visit(AST.UsingDeclaration usingDeclaration, object data)
 {
     Using u = new Using();
     u.Usings.Add(usingDeclaration.Namespace);
     cu.Usings.Add(u);
     return data;
 }
		public override object VisitUsing(Using @using, object data)
		{
			if (usings != null && [email protected]) {
				usings[@using.Name] = @using.Name;
			}
			return base.VisitUsing(@using, data);
		}
Exemplo n.º 4
0
        public async Task <Using <T> > UseIfAsync(long maxUseCountCondition, IContext ctx = default)
        {
            Using <long> innerUsing = default;

            try {
                UseIf(maxUseCountCondition: maxUseCountCondition, @using: out innerUsing);
                if (!innerUsing.IsInitialized)
                {
                    return(default);
Exemplo n.º 5
0
 internal static TResult SelectMany <T, TSecond, TResult>
     (this Using <T> source, Func <T, Using <TSecond> > second, Func <T, TSecond, TResult> selector)
     where T : IDisposable
     where TSecond : IDisposable
 {
     using (source.Source)
         using (var s = second(source.Source).Source)
             return(selector(source.Source, s));
 }
Exemplo n.º 6
0
        bool MatchesUsing(Using @using)
        {
            var parent = @using.Parent as UsingDeclaration;

            return(parent != null &&
                   parent.StartLocation.Line == _line &&
                   parent.StartLocation.Column < _column &&
                   parent.EndLocation.Column > _column &&
                   (@using.Name == _entityName || (@using.IsAlias && @using.Alias.ToString() == _entityName)));
        }
		public override object VisitUsing(Using @using, object data)
		{
			base.VisitUsing(@using, data);
			if (DefaultImportsToRemove != null && [email protected]) {
				if (DefaultImportsToRemove.Contains(@using.Name)) {
					RemoveCurrentNode();
				}
			}
			return null;
		}
Exemplo n.º 8
0
        public void Create_Using()
        {
            var @using = new Using("BITS.Compilers.CSharp.Test");

            var expectet = Comparer.Create_Using();
            var actual = @using.ToString();

            Assert.AreEqual(expectet, actual);
            Console.WriteLine(actual);
        }
Exemplo n.º 9
0
        public void SetUp()
        {
            serviceLocator = new ThreadedServiceLocator(new SiegeAdapter());

            mocks          = new MockRepository();
            sessionFactory = mocks.DynamicMock <ISessionFactory>();

            serviceLocator.Register(
                Using.Convention(new NHibernateConvention <ThreadedUnitOfWorkStore, NullDatabase>(sessionFactory)));
        }
Exemplo n.º 10
0
        protected override void OnApplicationStarted()
        {
            base.OnApplicationStarted();

            ServiceLocator
            .Register(Using.Convention <TemplateConvention>())
            .Register(Using.Convention <ControllerConvention <HomeController> >())
            .Register(Given <WCFAdapter> .Then <WCFAdapter>())
            .Register(Given <IConfigurationManager> .Then <ServiceBusConfigurationManager>())
            .Register(Given <IChannelManagerFactory> .Then <WCFChannelManagerFactory>())
            .Register(Given <IChannelManager <IWCFProtocol> > .ConstructWith(x =>
            {
                var config = x.GetInstance <IConfigurationManager>();
                return(x.GetInstance <WCFChannelManagerFactory>().Create <IWCFProtocol>(config.ServiceBusEndPoint));
            }))
            .Register(Given <WCFProxy <IWCFProtocol> > .Then <WCFProxy <IWCFProtocol> >())
            .Register(Given <AccountSubscriber> .Then <AccountSubscriber>())
            .Register(Given <IMessageBucket> .Then <HttpMessageBucket>())
            .Register(Given <IFormsAuthenticationService> .Then <FormsAuthenticationService>());

            MapMessage <LogOnAccountMessage, WCFAdapter>();

            AddSubscriber <AccountSubscriber, MemberAuthenticatedMessage>();
            AddSubscriber <AccountSubscriber, MemberFailedAuthenticationMessage>();
            AddSubscriber <AccountSubscriber, MessageValidationFailedMessage <LogOnAccountMessage> >();

            var engine = new TemplateViewEngine(() => ServiceLocator.Store.Get <IContextStore>().Items);

            engine.UseConvention(new SampleConvention());

            //engine
            //    .For<HomeController>(controller => controller.Index())
            //    .Map(
            //             To.Path("LOL").When<bool>(x => x)
            //        );
            //engine
            //    .ForPartial("LogOnUserControl")
            //    .Map(
            //            To.Path("~/Views/Shared/LogOnUserControl.ascx"),
            //            To.Path("~/Views/LOL/LOLUserControl.ascx").When<bool>(x => x)
            //        );

            //engine
            //    .Map(
            //            To.Path("~/Views/Home/"),
            //            To.Path("~/Views/LOL/").When<bool>(x => x),
            //            To.Master("~/Views/Shared/Site.master"),
            //            To.Master("~/Views/LOL/LOL.master").When<bool>(x => x)
            //        );

            ViewEngines.Engines.Clear();
            ViewEngines.Engines.Add(engine);

            ServiceLocator.AddContext(true);
        }
Exemplo n.º 11
0
 public override void VisitUsingDirective(UsingDirectiveSyntax elNodo)
 {
     try {
         Using nuevoUsing = new Using();
         nuevoUsing.UsingDeclarado = elNodo.Name.ToFullString();
         UsingsConstruidos.Add(nuevoUsing);
     } catch (Exception laExcepcion) {
         Bitacoras.Registrador elRegistrador = new Bitacoras.Registrador();
         elRegistrador.Registre(laExcepcion, IdSolucion, BC.Componentes.AnalizadorCodigoFuente);
     }
 }
 private string GetShortReferenceTypeName(Using usi)
 {
     if (usi.IsAlias)
     {
         return(usi.Name);
     }
     else
     {
         return(usi.Name.Substring(usi.Name.LastIndexOf('.') + 1));
     }
 }
 private string GetFullyQualifiedName(Using usi)
 {
     if (usi.IsAlias)
     {
         return(usi.Alias.Type);
     }
     else
     {
         return(usi.Name);
     }
 }
        public override object TrackedVisitUsingDeclaration(UsingDeclaration usingDeclaration, object data)
        {
            Using  usi  = (Using)usingDeclaration.Usings[0];
            string type = GetShortReferenceTypeName(usi);

            if (similarTypes.Contains(type))
            {
                RemoveCurrentNode();
            }
            return(null);
        }
Exemplo n.º 15
0
 private static DomainGenerator EmployeeGenerator(ISession session)
 {
     return(Using.TheseConventions()
            .With <Employee>(options => options.Ignore(employee => employee.Id))
            .With <Employee>(options => options.Length(employee => employee.FirstName, 1, 50))
            .With <Employee>(options => options.Length(employee => employee.LastName, 1, 75))
            .With <Employee>(options => options.Length(employee => employee.Title, 1, 50))
            .With <Employee>(options => options.Range(employee => employee.Salary, 1700, 3500))
            .With <Employee>(options => options.Length(employee => employee.Phone, 1, 15))
            .ForEach <Employee>(employee => session.Save(employee)));
 }
        private R2PBUsing ConstruyaElUsing(Using elUsing, int elIdClase, int elIdProyecto, int elIdPaquete)
        {
            R2PBUsing elUsingConvertido = new R2PBUsing();

            elUsingConvertido.IdClase        = elIdClase;
            elUsingConvertido.UsingDeclarado = elUsing.UsingDeclarado;
            elUsingConvertido.IdProyecto     = elIdProyecto;
            elUsingConvertido.IdPaquete      = elIdPaquete;

            return(elUsingConvertido);
        }
Exemplo n.º 17
0
    protected float Move()
    {
        Using?.Invoke();

        if (_movementController.MoveTime < MaxMoveTime)
        {
            _movementController.MoveTime += Time.deltaTime;
        }

        return(_movementController.MovementSpeed.Evaluate(_movementController.MoveTime));
    }
Exemplo n.º 18
0
		private static void Add_Usings(Document document, XElement doc_element)
		{
			foreach ( var using_element in doc_element.Elements("Using") )
			{
				var using_ = new Using();

				using_.assembly = using_element.Attribute_Value("Source");

				document.usings.Add(using_);
			}
		}
Exemplo n.º 19
0
 internal void AddUsing(string @namespace)
 {
     if (Using == null)
     {
         Using = new List <string>();
     }
     if (Using.Contains(@namespace))
     {
         return;
     }
     Using.Add(@namespace);
 }
Exemplo n.º 20
0
 public override object TrackedVisitUsing(Using us, object data)
 {
     if (us.IsAlias)
     {
         Add(us.Alias.Type);
     }
     else
     {
         Add(us.Name);
     }
     return(base.TrackedVisitUsing(us, data));
 }
Exemplo n.º 21
0
        protected override void OnApplicationStarted()
        {
            RegisterGlobalFilters(GlobalFilters.Filters);
            BundleTable.Bundles.RegisterTemplateBundles();

            base.OnApplicationStarted();

            ServiceLocator
            .Register(Given <IAuthenticationProvider> .Then <WebAuthenticationProvider>())
            .Register(Using.Convention(new SqlSecurityAdminConvention()))
            .Register(Using.Convention <ControllerConvention <AccountController> >());
        }
Exemplo n.º 22
0
        /// <summary>
        /// 格式化输出类代码。
        /// </summary>
        /// <returns>返回代码字符串。</returns>
        public override string ToString()
        {
            var header = new StringBuilder();

            header.Append("namespace ").AppendLine(Namespace);
            header.AppendLine("{");
            var builder = new StringBuilder();

            if (!string.IsNullOrEmpty(Desc))
            {
                builder.AppendLine("    /// <summary>");
                builder.Append("    /// ").Append(Desc).AppendLine("。");
                builder.AppendLine("    /// </summary>");
            }

            builder.Append("    public class ").Append(Name.Normalize());
            if (Base != null && Base.Count > 0)
            {
                builder.Append(" : ");
                var baseClass = Base.FirstOrDefault(x => x.StartsWith('I'));
                if (baseClass != null)
                {
                    Base.Remove(baseClass);
                    Base.Insert(0, baseClass);
                }

                builder.Append(string.Join(", ", Base));
            }

            builder.AppendLine();
            builder.AppendLine("    {");
            foreach (var property in Props)
            {
                property.Class = this;
                builder.AppendLine(property.ToString());
            }
            builder.AppendLine("    }");
            builder.AppendLine("}");

            if (Using != null && Using.Count > 0)
            {
                foreach (var @using in Using.Distinct())
                {
                    header.AppendLine($"    using {@using};");
                }

                header.AppendLine();
            }

            builder.Insert(0, header);
            return(builder.ToString());
        }
        protected override void OnApplicationStarted()
        {
            ServiceLocator
            .Register(Using.Convention <AspNetMvcConvention>())
            .Register(Using.Convention <ServiceBusConvention>())
            .Register(Given <MessageMap> .Then(Map));

            AddResponse <ViewResponse>("view");
            AddResponse <JsonResponse>("json");

            RouteTable.Routes.Add(ServiceLocator.GetInstance <ServiceBusRoute>());
            base.OnApplicationStarted();
        }
Exemplo n.º 24
0
        public virtual void ShouldProxyAllTypes()
        {
            locator.Register(Using.Convention <SampleProxyAttributeConvention>());
            locator.Register(Using.Convention <ProxyConvention>());
            locator.Register(Given <TestType2> .Then <TestType2>());

            var testType2 = locator.GetInstance <TestType2>();

            Assert.AreEqual("lolarg1", testType2.Test("arg1", "arg2"));
            Assert.AreEqual(3, Counter.Count);

            Counter.Count = 0;
        }
Exemplo n.º 25
0
 private bool Contains(IList list, UsingDeclaration us)
 {
     foreach (UsingDeclaration usingDeclaration in list)
     {
         Using usi = (Using)usingDeclaration.Usings[0];
         Using uss = (Using)us.Usings[0];
         if (usi.Name == uss.Name)
         {
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 26
0
        public static void Create(ISession session)
        {
            var customers = Using.TheseConventions()
                            .With <Customer>(options => options.Length(customer => customer.Name, 5, 100))
                            .With <Customer>(options => options.Range(customer => customer.DiscountPercentage, 0, 25))
                            .ForEach <Customer>(customer => session.Save(customer))
                            .Many <Customer>(20, 40)
                            .ToArray();

            var managers = EmployeeGenerator(session)
                           .Many <Employee>(2);

            var employees = EmployeeGenerator(session)
                            .ForEach <Employee>(employee => Maybe.Do(() => managers.PickOne().AddSubordinate(employee)))
                            .Many <Employee>(20)
                            .ToArray();

            var suppliers = Using.TheseConventions()
                            .With <Supplier>(options => options.Length(supplier => supplier.Website, 1, 100))
                            .With <Supplier>(options => options.Length(supplier => supplier.Name, 5, 25))
                            .ForEach <Supplier>(supplier => session.Save(supplier))
                            .Many <Supplier>(20)
                            .ToArray();

            var products = Using.TheseConventions()
                           .ForEach <ProductSource>(productsource => session.Save(productsource))
                           .With <Product>(options => options.Ignore(product => product.Version))
                           .With <Product>(options => options.For(
                                               product => product.Category,
                                               ProductCategory.Beverages,
                                               ProductCategory.Condiments,
                                               ProductCategory.DairyProducts,
                                               ProductCategory.Produce))
                           .With <Product>(g => g.Method <double>(0, 5, (product, d) => product.AddSource(suppliers.PickOne(), d)))
                           .With <Product>(options => options.Length(product => product.Name, 1, 50))
                           .ForEach <Product>(product => session.Save(product))
                           .Many <Product>(50)
                           .ToArray();

            Using.TheseConventions()
            .With <OrderItem>(options => options.For(item => item.Product, products))
            .OneToMany <Order, OrderItem>(1, 5, (order, item) => order.AddItem(item))
            .With <Order>(options => options.For(order => order.Customer, customers))
            .With <Order>(options => options.For(order => order.Employee, employees))
            .OneToOne <Order, Address>((order, address) => order.DeliveryAddress = address)
            .ForEach <Order>(order => session.Save(order))
            .Many <Order>(50);

            session.Flush();
        }
Exemplo n.º 27
0
        /// <summary>
        /// Finds all elements matching the criteria.
        /// </summary>
        /// <param name="context">An <see cref="T:OpenQA.Selenium.ISearchContext"/> object to use to search for the elements.</param>
        /// <returns>
        /// A <see cref="T:System.Collections.ObjectModel.ReadOnlyCollection`1"/> of all <see cref="T:OpenQA.Selenium.IWebElement">WebElements</see>
        ///             matching the current criteria, or an empty list if nothing matches.
        /// </returns>
        public override ReadOnlyCollection <IWebElement> FindElements(ISearchContext context)
        {
            By by = null;

            if (_selector.StartsWith("//"))
            {
                by = XPath(_selector);
            }
            else
            {
                by = IsJavaScriptEnabled(context, _jQueryTest) ? Using.JQuery(_selector) : CssSelector(_selector);
            }

            return(context.FindElements(by));
        }
Exemplo n.º 28
0
 public override void OnUsing(Using p)
 {
     Write("using {0}", p.Namespace);
     if (null != p.AssemblyReference)
     {
         Write(" from ");
         Write(p.AssemblyReference.Name);
     }
     if (null != p.Alias)
     {
         Write(" as ");
         Write(p.Alias.Name);
     }
     WriteLine();
 }
Exemplo n.º 29
0
        /// <summary>
        /// Runs a function and retries if any exception is thrown, using a linear backoff strategy.
        /// </summary>
        /// <param name="operation">The operation to execute.</param>
        /// <param name="retryCount">Optional number of retries; DEFAULT is <see cref="DefaultRetryCount" />.</param>
        /// <param name="backOffDelay">Optional backoff delay; DEFAULT is <see cref="DefaultLinearBackoffDelay" />.</param>
        /// <returns>
        /// A task.
        /// </returns>
        public static async Task WithRetryAsync(this Func <Task> operation, int retryCount = DefaultRetryCount, TimeSpan backOffDelay = default(TimeSpan))
        {
            if (operation == null)
            {
                throw new ArgumentNullException(nameof(operation));
            }

            var localBackOff = backOffDelay == default(TimeSpan) ? DefaultLinearBackoffDelay : backOffDelay;

            await Using
            .LinearBackOff(localBackOff)
            .WithMaxRetries(retryCount)
            .RunAsync(operation)
            .Now();
        }
Exemplo n.º 30
0
 private string GetAliasUsing(IList usings, TypeReference type)
 {
     foreach (UsingDeclaration usingDeclaration in usings)
     {
         Using us = (Using)usingDeclaration.Usings[0];
         if (us.IsAlias)
         {
             if (us.Name == type.Type)
             {
                 return(us.Alias.Type);
             }
         }
     }
     return(null);
 }
Exemplo n.º 31
0
        /// <summary>
        /// Runs a function and retries if any exception is thrown, using a linear backoff strategy.
        /// </summary>
        /// <param name="operation">The operation to execute.</param>
        /// <param name="retryCount">Optional number of retries; DEFAULT is <see cref="DefaultRetryCount" />.</param>
        /// <param name="backOffDelay">Optional backoff delay; DEFAULT is <see cref="DefaultLinearBackoffDelay" />.</param>
        /// <returns>
        /// A task.
        /// </returns>
        public static void WithRetry(this Action operation, int retryCount = DefaultRetryCount, TimeSpan backOffDelay = default(TimeSpan))
        {
            if (operation == null)
            {
                throw new ArgumentNullException(nameof(operation));
            }

            var localBackOff = backOffDelay == default(TimeSpan) ? DefaultLinearBackoffDelay : backOffDelay;

            Using
            .LinearBackOff(localBackOff)
            .WithMaxRetries(retryCount)
            .Run(operation)
            .Now();
        }
Exemplo n.º 32
0
 public object VisitUsing(Using @using, object data)
 {
     B.Import import;
     if (@using.IsAlias)
     {
         import             = new B.Import(@using.Alias.Type, null, new B.ReferenceExpression(@using.Name));
         import.LexicalInfo = GetLexicalInfo(@using);
     }
     else
     {
         import = new B.Import(GetLexicalInfo(@using), @using.Name);
     }
     module.Imports.Add(import);
     return(import);
 }
Exemplo n.º 33
0
        public void visible(Using u, bool v)
        {
            //
            if (v)
            {
                usings.Add(u);
            }
            else if (usings.Remove(u) == false)
            {
                Debug.LogError("loadingObjects.Remove(o) == false  u=" + u, this);
            }

            StopAllCoroutines();
            gameObject.SetActive(true);
            StartCoroutine(visibleE());
        }
Exemplo n.º 34
0
        public async Task UsingTest()
        {
            var i = 0;

            var asyncDisposable = await Using.Async(new AsyncDisposableClass(), async adc =>
            {
                Assert.False(adc.IsDisposed);
                await Task.Delay(20);
                i++;
                return(adc);
            });

            Assert.NotNull(asyncDisposable);
            Assert.True(asyncDisposable.IsDisposed);
            Assert.Equal(1, i);
        }
Exemplo n.º 35
0
        public static void AddDefaultUsings(Game game)
        {
            //TODO add functions here as well later
            Using defaults = new Using();
            defaults.File = null;
            List<string> defaultEvts = new List<string>()
            {
                "AttributeChanges",
                "SceneStarts",
                "TriggerOccurs",
                "OnCreate"
            };
            addDefaults(defaults, defaultEvts, "Event");
            List<string> defaultComponents = new List<string>()
            {
                "Transform"
            };
            addDefaults(defaults, defaultComponents, "Component");
            List<string> defaultActions = new List<string>()
            {
                "PushScene",
                "PopScene",
                "ChangeScene",
                "PopScene",
                "FireTrigger",
                "CreateEntity",
                "Destroy",
                "CreateTimer",
                "PauseTimers",
                "ResumeTimers",
                "Quit",
                "PointTowards"
            };
            addDefaults(defaults, defaultActions, "Action");

            List<string> defaultManagers = new List<string>()
            {
                "Time"
            };

            addDefaults(defaults, defaultManagers, "Manager");
            game.AddUsing(defaults);
        }
Exemplo n.º 36
0
        public void AddComponentWithExistingDefine()
        {
            Game game = new Game("Test Game");

            Using use = new Using() { File = Path.GetFileName(typeof(TransformComponent).Assembly.Location) };
            game.AddUsing(use);

            Define define = new Define(TransformComponentShort, TransformComponentType);
            use.AddDefine(define);

            Entity entity = new Entity() { Name = "entity" };

            Component component = new Component(game.GetPlugin(TransformComponentShort));
            entity.AddComponent(component);
            game.AddPrototype(entity);

            Assert.AreEqual(1, game.Usings.Count);
            Assert.AreEqual(1, game.Usings.Single().Defines.Count(x => x.Name == TransformComponentShort && x.Class == TransformComponentType));
            Assert.AreEqual(TransformComponentShort, component.Type);
        }
Exemplo n.º 37
0
void case_950()
#line 7272 "ps-parser.jay"
{
	  	CheckIsPlayScript("using", GetLocation(yyVals[-2+yyTop]));
	  
		Error_SyntaxError (yyToken);
		
		yyVal = new Using ((Expression) yyVals[-1+yyTop], null, GetLocation (yyVals[-3+yyTop]));
		lbag.AddStatement (yyVal, GetLocation (yyVals[-2+yyTop]));
	  }
Exemplo n.º 38
0
		public virtual object Visit (Using usingStatement)
		{
			return null;
		}
Exemplo n.º 39
0
 private static void addDefaults(Using uses, List<string> defaults, string type)
 {
     foreach (string defaultName in defaults)
         uses.AddDefine(new Define(defaultName, "Kinectitude.Core." + type + "s." + defaultName + type));
 }
Exemplo n.º 40
0
        public void GetDefinedPlugin()
        {
            Game game = new Game("Test Game");

            Using use = new Using() { File = "Kinectitude.Core.dll" };
            use.AddDefine(new Define(TransformComponentShort, TransformComponentType));
            game.AddUsing(use);

            Plugin plugin = game.GetPlugin(TransformComponentShort);

            Assert.IsNotNull(plugin);
            Assert.AreEqual(TransformComponentType, plugin.ClassName);
        }
Exemplo n.º 41
0
		public sealed override object VisitUsing(Using @using, object data) {
			BeginVisit(@using);
			object result = TrackedVisitUsing(@using, data);
			EndVisit(@using);
			return result;
		}
Exemplo n.º 42
0
void case_1015()
#line 6799 "cs-parser.jay"
{
		if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE)
			Warning_EmptyStatement (GetLocation (yyVals[0+yyTop]));
	  
		Using u = new Using ((Using.VariableDeclaration) yyVals[-1+yyTop], (Statement) yyVals[0+yyTop], GetLocation (yyVals[-8+yyTop]));
		lbag.AddStatement (u, GetLocation (yyVals[-7+yyTop]), GetLocation (yyVals[-2+yyTop]));
		current_block.AddStatement (u);
		yyVal = end_block (GetLocation (yyVals[-2+yyTop]));
	  }
Exemplo n.º 43
0
void case_1016()
#line 6809 "cs-parser.jay"
{
		if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE)
			Warning_EmptyStatement (GetLocation (yyVals[0+yyTop]));
	  
		yyVal = new Using ((Expression) yyVals[-2+yyTop], (Statement) yyVals[0+yyTop], GetLocation (yyVals[-4+yyTop]));
		lbag.AddStatement (yyVal, GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-1+yyTop]));
	  }
		public virtual object VisitUsing(Using @using, object data) {
			throw new global::System.NotImplementedException("Using");
		}
Exemplo n.º 45
0
		public virtual object VisitUsing(Using @using, object data) {
			Debug.Assert((@using != null));
			Debug.Assert((@using.Alias != null));
			return @using.Alias.AcceptVisitor(this, data);
		}
Exemplo n.º 46
0
 /// <summary>
 /// header := [using]*
 /// </summary>
 private void readHeader()
 {
     while (curt == Token.USING)
       {
     Using u = readUsing();
     if (usings == null) usings = new Using[8];
     if (numUsings  >= usings.Length)
     {
       Using[] temp = new Using[usings.Length*2];
       System.Array.Copy(usings, 0, temp, 0, numUsings);
       usings = temp;
     }
     usings[numUsings++] = u;
       }
 }
Exemplo n.º 47
0
        public void AddUsing()
        {
            bool collectionChanged = false;

            Game game = new Game("Test Game");
            game.Usings.CollectionChanged += (o, e) => collectionChanged = true;

            Using use = new Using() { File = "Test.dll" };
            game.AddUsing(use);

            Assert.IsTrue(collectionChanged);
            Assert.AreEqual(game.Usings.Count(), 1);
            Assert.AreEqual(game.Usings.First().File, "Test.dll");
        }
Exemplo n.º 48
0
void case_949()
#line 7262 "ps-parser.jay"
{
	  	CheckIsPlayScript("using", GetLocation(yyVals[-3+yyTop]));

		if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE)
			Warning_EmptyStatement (GetLocation (yyVals[0+yyTop]));
	  
		yyVal = new Using ((Expression) yyVals[-2+yyTop], (Statement) yyVals[0+yyTop], GetLocation (yyVals[-4+yyTop]));
		lbag.AddStatement (yyVal, GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-1+yyTop]));
	  }
Exemplo n.º 49
0
        private static string ProcessRuleReplacementsWithMatchTags(string responseString, Using? outboundRuleUsing,
            IEnumerable<MatchTag> matchTags, string rewritePattern, string rewriteValue)
        {
            const string startKey = "start";
            const string innerKey = "inner";
            const string endKey = "end";
            const string nameKey = "name";
            const string startquoteKey = "startquote";
            const string valueKey = "value";
            const string endquoteKey = "endquote";

            const string tagPatternFormat =
                @"(?<" + startKey + @"><{0}\s+)(?<" + innerKey + @">.*?{1}=(?:""|').*?)(?<" + endKey + @">\s*/?>)";

            const string attributePatternFormat =
                @"(?<" + nameKey + @">{0}=)(?<" + startquoteKey + @">""|')(?<" + valueKey + @">.*?)(?<" +
                endquoteKey + @">""|')";

            var output = responseString;

            foreach (var matchTag in matchTags)
            {
                var tag = matchTag.Tag;
                var attribute = matchTag.Attribute;
                var tagPattern = string.Format(tagPatternFormat, tag, attribute);
                var tagRegex = new Regex(tagPattern);

                output = tagRegex.Replace(responseString, tagMatch =>
                {
                    var tagMatchGroups = tagMatch.Groups;
                    var tagStart = tagMatchGroups[startKey].Value;
                    var tagInnards = tagMatchGroups[innerKey].Value;
                    var tagEnd = tagMatchGroups[endKey].Value;
                    var attributePattern = string.Format(attributePatternFormat, attribute);
                    var attributeRegex = new Regex(attributePattern);

                    var newTagInnards = attributeRegex.Replace(tagInnards, attributeMatch =>
                    {
                        var attributeMatchGroups = attributeMatch.Groups;
                        var attributeValue = attributeMatchGroups[valueKey].Value;

                        var attributeValueRegex = new Regex(rewritePattern);
                        var attributeValueMatch = attributeValueRegex.Match(attributeValue);

                        if (attributeValueMatch.Success)
                        {
                            var attributeName = attributeMatchGroups[nameKey].Value;
                            var attributeStartQuote = attributeMatchGroups[startquoteKey].Value;
                            var attributeEndQuote = attributeMatchGroups[endquoteKey].Value;

                            // need to determine where the match occurs within the original string
                            var attributeValueMatchIndex = attributeValueMatch.Index;
                            var attributeValueMatchLength = attributeValueMatch.Length;
                            string attributeValueReplaced;

                            if (outboundRuleUsing == Using.ExactMatch)
                            {
                                attributeValueReplaced = attributeValueMatch.Value.Replace(
                                    attributeValueMatch.Value, rewriteValue);
                            }
                            else
                            {
                                attributeValueReplaced = RewriteHelper.ReplaceRuleBackReferences(attributeValueMatch,
                                    rewriteValue);
                            }

                            var newAttributeValue = attributeValue.Substring(0, attributeValueMatchIndex) +
                                                       attributeValueReplaced +
                                                       attributeValue.Substring(attributeValueMatchIndex +
                                                                                attributeValueMatchLength);

                            var attributeOutput = attributeName + attributeStartQuote + newAttributeValue +
                                                  attributeEndQuote;

                            return attributeOutput;
                        }

                        return attributeMatch.Value;
                    });

                    var tagOutput = tagStart + newTagInnards + tagEnd;

                    return tagOutput;
                });
            }
            return output;
        }
Exemplo n.º 50
0
		public virtual object VisitUsing(Using @using, object data) {
			Debug.Assert((@using != null));
			Debug.Assert((@using.Alias != null));
			nodeStack.Push(@using.Alias);
			@using.Alias.AcceptVisitor(this, data);
			@using.Alias = ((TypeReference)(nodeStack.Pop()));
			return null;
		}
Exemplo n.º 51
0
void case_1017()
#line 6817 "cs-parser.jay"
{
		Error_SyntaxError (yyToken);
		
		yyVal = new Using ((Expression) yyVals[-1+yyTop], null, GetLocation (yyVals[-3+yyTop]));
		lbag.AddStatement (yyVal, GetLocation (yyVals[-2+yyTop]));
	  }
Exemplo n.º 52
0
		public virtual object TrackedVisitUsing(Using @using, object data) {
			return base.VisitUsing(@using, data);
		}
Exemplo n.º 53
0
void case_948()
#line 7250 "ps-parser.jay"
{
	  	CheckIsPlayScript("using", GetLocation(yyVals[-7+yyTop]));
	  	
		if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE)
			Warning_EmptyStatement (GetLocation (yyVals[0+yyTop]));
	  
		Using u = new Using ((Using.VariableDeclaration) yyVals[-1+yyTop], (Statement) yyVals[0+yyTop], GetLocation (yyVals[-8+yyTop]));
		lbag.AddStatement (u, GetLocation (yyVals[-7+yyTop]), GetLocation (yyVals[-2+yyTop]));
		current_block.AddStatement (u);
		yyVal = end_block (GetLocation (yyVals[-2+yyTop]));
	  }
Exemplo n.º 54
0
        private Using CreateUsing(ParseTreeNode node)
        {
            Using use = new Using() { File = node.ChildNodes.First(child => child.Term == grammar.ClassName).Token.ValueString };

            IEnumerable<ParseTreeNode> defines = grammar.GetOfType(node, grammar.Definitions);

            foreach (ParseTreeNode define in defines)
            {
                string className = define.ChildNodes.First(child => child.Term == grammar.ClassName).Token.ValueString;
                use.AddDefine(new Define(grammar.GetName(define), className));
            }

            return use;
        }
			public override object Visit (Using usingStatement)
			{
				var result = new UsingStatement ();
				var location = LocationsBag.GetLocations (usingStatement);
				
				result.AddChild (new CSharpTokenNode (Convert (usingStatement.loc), UsingStatement.UsingKeywordRole), UsingStatement.UsingKeywordRole);
				if (location != null)
					result.AddChild (new CSharpTokenNode (Convert (location [0]), Roles.LPar), Roles.LPar);
				if (usingStatement.Expr != null)
					result.AddChild ((AstNode)usingStatement.Expr.Accept (this), UsingStatement.ResourceAcquisitionRole);
				
				if (location != null && location.Count > 1)
					result.AddChild (new CSharpTokenNode (Convert (location [1]), Roles.RPar), Roles.RPar);
				
				if (usingStatement.Statement != null)
					result.AddChild ((Statement)usingStatement.Statement.Accept (this), Roles.EmbeddedStatement);
				return result;
			}
Exemplo n.º 56
0
        public void RemoveUsing()
        {
            int eventsFired = 0;

            Game game = new Game("Test Game");
            game.Usings.CollectionChanged += (o, e) => eventsFired++;

            Using use = new Using() { File = "Test.dll" };
            game.AddUsing(use);
            game.RemoveUsing(use);

            Assert.AreEqual(2, eventsFired);
            Assert.AreEqual(game.Usings.Count(), 0);
        }
Exemplo n.º 57
0
		public override object VisitUsing(Using @using, object data)
		{
			return base.VisitUsing(@using, data);
		}
Exemplo n.º 58
0
	void ImportClause(
#line  319 "VBNET.ATG" 
out Using u) {

#line  321 "VBNET.ATG" 
		string qualident  = null;
		TypeReference aliasedType = null;
		u = null;
		
		Qualident(
#line  325 "VBNET.ATG" 
out qualident);
		if (la.kind == 10) {
			lexer.NextToken();
			TypeName(
#line  326 "VBNET.ATG" 
out aliasedType);
		}

#line  328 "VBNET.ATG" 
		if (qualident != null && qualident.Length > 0) {
		if (aliasedType != null) {
			u = new Using(qualident, aliasedType);
		} else {
			u = new Using(qualident);
		}
		}
		
	}