Exemplo n.º 1
0
 public FullUsingStatement(ReferenceBuilder type, string name, Expression obj, Statement[] body)
 {
     this.type = type;
     this.name = name;
     this.obj  = obj;
     this.body = body;
 }
Exemplo n.º 2
0
        static PageHelper CreatePageHelper(HttpContextBase httpContext)
        {
            var scriptReferenceBuilder     = new ReferenceBuilder(Manager.ScriptModuleContainer);
            var stylesheetReferenceBuilder = new ReferenceBuilder(Manager.StylesheetModuleContainer);
            var useModules = Manager.Configuration.ShouldUseModules(httpContext);

            return(new PageHelper(useModules, Manager.Configuration.BufferHtmlOutput, Manager.Configuration.Handler, scriptReferenceBuilder, stylesheetReferenceBuilder, VirtualPathUtility.ToAbsolute));
        }
Exemplo n.º 3
0
        private Reference NewAuthor(Action <ReferenceBuilder> setUp = null)
        {
            ReferenceBuilder referenceBuilder = new ReferenceBuilder();

            setUp?.Invoke(referenceBuilder);

            return(referenceBuilder.Build());
        }
        private Reference NewUser(Action <ReferenceBuilder> setUp = null)
        {
            ReferenceBuilder userBuilder = new ReferenceBuilder();

            setUp?.Invoke(userBuilder);

            return(userBuilder.Build());
        }
        protected static Reference NewReference(Action <ReferenceBuilder> setUp = null)
        {
            ReferenceBuilder referenceBuilder = new ReferenceBuilder();

            setUp?.Invoke(referenceBuilder);

            return(referenceBuilder.Build());
        }
Exemplo n.º 6
0
        static void AddScriptBundle(ScriptBundle bundle, string pageLocation, Action <ScriptBundle> customizeBundle)
        {
            if (customizeBundle != null)
            {
                customizeBundle(bundle);
            }

            ReferenceBuilder.Reference(bundle, pageLocation);
        }
Exemplo n.º 7
0
        public void ThisDatabase_Reference_Has_FileName_And_LogicalName()
        {
            var builder    = new ReferenceBuilder();
            var customData = builder.BuildThisDatabaseReference("filename", "logicalName");

            Assert.AreEqual(2, customData.Items.Count);
            Assert.IsNotNull(customData.Items.FirstOrDefault(p => p.Name == "FileName" && p.Value == "filename"));
            Assert.IsNotNull(customData.Items.FirstOrDefault(p => p.Name == "LogicalName" && p.Value == "logicalName"));
        }
Exemplo n.º 8
0
        public ReferenceBuilder_Reference_Tests()
        {
            moduleContainer = new Mock<IModuleContainer<ScriptModule>>();
            moduleFactory = new Mock<IModuleFactory<ScriptModule>>();
            application = new Mock<ICassetteApplication>();
            builder = new ReferenceBuilder<ScriptModule>(moduleContainer.Object, moduleFactory.Object, Mock.Of<IPlaceholderTracker>(), application.Object);

            moduleContainer.Setup(c => c.IncludeReferencesAndSortModules(It.IsAny<IEnumerable<Module>>()))
                           .Returns<IEnumerable<Module>>(ms => ms);
        }
Exemplo n.º 9
0
        public ReferenceBuilder_Reference_Tests()
        {
            application = new Mock<ICassetteApplication>();
            bundleFactories = new Dictionary<Type, IBundleFactory<Bundle>>();
            bundleContainer = new Mock<IBundleContainer>();
            bundleContainer.Setup(c => c.IncludeReferencesAndSortBundles(It.IsAny<IEnumerable<Bundle>>()))
                           .Returns<IEnumerable<Bundle>>(ms => ms);

            builder = new ReferenceBuilder(bundleContainer.Object, bundleFactories, Mock.Of<IPlaceholderTracker>(), new CassetteSettings());
        }
Exemplo n.º 10
0
        public void OtherDatabase_Reference_Has_FileName_And_LogicalName_And_ExternalParts_And_SuppressMissingDependenciesErrors()
        {
            var          builder    = new ReferenceBuilder();
            const string expected   = "bleurgh";
            var          customData = builder.BuildOtherDatabaseReference(expected, "filename", "logicalName");

            Assert.AreEqual(4, customData.Items.Count);
            Assert.IsNotNull(customData.Items.FirstOrDefault(p => p.Name == "FileName" && p.Value == "filename"));
            Assert.IsNotNull(customData.Items.FirstOrDefault(p => p.Name == "LogicalName" && p.Value == "logicalName"));
            Assert.IsNotNull(customData.RequiredSqlCmdVars.Any(p => p == expected));
        }
Exemplo n.º 11
0
        public void GivenLocationAlreadyRenderedButHtmlRewrittingEnabled_WhenAddReferenceToThatLocation_ThenBundleStillAdded()
        {
            builder = new ReferenceBuilder(
                bundleContainer.Object,
                bundleFactories, Mock.Of<IPlaceholderTracker>(),
                new CassetteSettings("") { IsHtmlRewritingEnabled = true }
            );
            var bundle = new ScriptBundle("~/test");
            bundleContainer.Setup(c => c.FindBundleContainingPath<Bundle>("~/test"))
                           .Returns(bundle);
            builder.Render<ScriptBundle>("test");

            builder.Reference("~/test", "test");

            builder.GetBundles("test").First().ShouldBeSameAs(bundle);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Get the URLs for bundles that have been referenced during the current request.
        /// </summary>
        /// <typeparam name="T">The type of bundles.</typeparam>
        /// <param name="pageLocation">Optional. The page location of bundles to return.</param>
        public static IEnumerable <string> GetReferencedBundleUrls <T>(string pageLocation)
            where T : Bundle
        {
            var bundles = ReferenceBuilder.GetBundles(pageLocation).OfType <T>();

            if (Application.Settings.IsDebuggingEnabled)
            {
                return(bundles
                       .SelectMany(GetAllAssets)
                       .Select(Application.Settings.UrlGenerator.CreateAssetUrl));
            }
            else
            {
                return(bundles
                       .Select(Application.Settings.UrlGenerator.CreateBundleUrl));
            }
        }
Exemplo n.º 13
0
        private static String AppendToPartTitleFromCelexAndToPar(String titleOfDocument, String docNumber, String toPar, int langId, String toParDefault)
        {
            if (String.IsNullOrEmpty(toPar))
            {
                return(titleOfDocument);
            }

            var toParText = toParDefault;

            try
            {
                var reference = ReferenceBuilder.Parse(docNumber, toPar);
                if (langId == 1)
                {
                    toParText = reference.GetDisplayTextInBulgarian(ReferenceDisplayOption.DisplayText, ReferenceFormOption.Long).SafeReplaceAtStart(",", String.Empty).Trim();
                }
                else if (langId == 2)
                {
                    toParText = reference.GetDisplayTextInGerman(ReferenceDisplayOption.DisplayText, ReferenceFormOption.Long).SafeReplaceAtStart(",", String.Empty).Trim();
                }
                else if (langId == 3)
                {
                    toParText = reference.GetDisplayTextInFrench(ReferenceDisplayOption.DisplayText, ReferenceFormOption.Long).SafeReplaceAtStart(",", String.Empty).Trim();
                }
                else if (langId == 4)
                {
                    toParText = reference.GetDisplayTextInEnglish(ReferenceDisplayOption.DisplayText, ReferenceFormOption.Long).SafeReplaceAtStart(",", String.Empty).Trim();
                }
                else if (langId == 5)
                {
                    toParText = reference.GetDisplayTextInItalian(ReferenceDisplayOption.DisplayText, ReferenceFormOption.Long).SafeReplaceAtStart(",", String.Empty).Trim();
                }
            }
            catch
            {
            }

            return($"{titleOfDocument} ({toParText})");
        }
Exemplo n.º 14
0
 /// <summary>
 /// Add a page reference to a script that initializes a global JavaScript variable with the given data.
 /// </summary>
 /// <param name="globalVariable">The name of the global JavaScript variable to assign.</param>
 /// <param name="data">The dictionary of data, serialized into JSON.</param>
 /// <param name="pageLocation">The optional page location of the script. This controls where it will be rendered.</param>
 public static void AddPageData(string globalVariable, IEnumerable <KeyValuePair <string, object> > data, string pageLocation = null)
 {
     ReferenceBuilder.Reference(new PageDataScriptBundle(globalVariable, data), pageLocation);
 }
Exemplo n.º 15
0
        public ReferenceBuilder_Render_Tests()
        {
            moduleContainer = new Mock<IModuleContainer<Module>>();
            moduleFactory = new Mock<IModuleFactory<Module>>();
            placeholderTracker = new Mock<IPlaceholderTracker>();
            application = Mock.Of<ICassetteApplication>();
            referenceBuilder = new ReferenceBuilder<Module>(moduleContainer.Object, moduleFactory.Object, placeholderTracker.Object, application);

            moduleContainer.Setup(c => c.IncludeReferencesAndSortModules(It.IsAny<IEnumerable<Module>>()))
                           .Returns<IEnumerable<Module>>(ms => ms);

            placeholderTracker.Setup(t => t.InsertPlaceholder(It.IsAny<Func<IHtmlString>>()))
                              .Returns(new HtmlString("output"));
        }
Exemplo n.º 16
0
 static PageHelper CreatePageHelper(HttpContextBase httpContext)
 {
     var scriptReferenceBuilder = new ReferenceBuilder(Manager.ScriptModuleContainer);
     var stylesheetReferenceBuilder = new ReferenceBuilder(Manager.StylesheetModuleContainer);
     var useModules = Manager.Configuration.ShouldUseModules(httpContext);
     return new PageHelper(useModules, Manager.Configuration.BufferHtmlOutput, Manager.Configuration.Handler, scriptReferenceBuilder, stylesheetReferenceBuilder, VirtualPathUtility.ToAbsolute);
 }
Exemplo n.º 17
0
        public ReferenceBuilder_Render_Tests()
        {
            bundleContainer = new Mock<IBundleContainer>();
            placeholderTracker = new Mock<IPlaceholderTracker>();
            application = Mock.Of<ICassetteApplication>();
            bundleFactories = new Dictionary<Type, IBundleFactory<Bundle>>();

            bundleContainer.Setup(c => c.IncludeReferencesAndSortBundles(It.IsAny<IEnumerable<Bundle>>()))
                           .Returns<IEnumerable<Bundle>>(ms => ms);

            placeholderTracker.Setup(t => t.InsertPlaceholder(It.IsAny<Func<string>>()))
                              .Returns(("output"));

            referenceBuilder = new ReferenceBuilder(bundleContainer.Object, bundleFactories, placeholderTracker.Object, new CassetteSettings());
        }
Exemplo n.º 18
0
 /// <summary>
 /// Gets the bundles that have been referenced during the current request.
 /// </summary>
 /// <param name="pageLocation">Optional. The page location of bundles to return.</param>
 public static IEnumerable <Bundle> GetReferencedBundles(string pageLocation)
 {
     return(ReferenceBuilder.GetBundles(pageLocation));
 }
Exemplo n.º 19
0
 public TryStatement Catch(ReferenceBuilder type, string name, params Statement[] statements)
 => new TryCatchStatement(this, type, name, statements);
Exemplo n.º 20
0
 static IHtmlString Render <T>(string location) where T : Bundle
 {
     return(new HtmlString(ReferenceBuilder.Render <T>(location)));
 }
Exemplo n.º 21
0
 /// <summary>
 /// Adds a reference to a bundle for the current page.
 /// </summary>
 /// <param name="assetPathOrBundlePathOrUrl">Either an application relative path to an asset file or bundle. Or a URL of an external resource.</param>
 /// <param name="pageLocation">The optional page location of the referenced bundle. This controls where it will be rendered.</param>
 public static void Reference(string assetPathOrBundlePathOrUrl, string pageLocation)
 {
     ReferenceBuilder.Reference(assetPathOrBundlePathOrUrl, pageLocation);
 }
Exemplo n.º 22
0
 public static void PassReference <TArg>(TypedReference tref, RefDelegate <TArg> del)
 {
     ReferenceBuilder <TArg> .PassRef(tref, del);
 }
Exemplo n.º 23
0
 public static TResult PassReference <TArg, TResult>(TypedReference tref, RefDelegate <TArg, TResult> del)
 {
     return(ReferenceBuilder <TArg, TResult> .PassRef(tref, del));
 }
        private DataStructureObjectImpl BuildDataStructure(string _foundedDataflowId)
        {
            try
            {
                string ConceptSchemeId = string.Format(FlyConfiguration.ConceptSchemeFormat, _foundedDataflowId);
                List <IComponentMutableObject> components = new List <IComponentMutableObject>();

                if (!this.ReferencesObject.Concepts.ContainsKey(ConceptSchemeId))
                {
                    ConceptSchemeManager gdf = new ConceptSchemeManager((ISdmxParsingObject)this.parsingObject.Clone(), this.versionTypeResp);
                    ReferencesObject.Concepts.Add(string.Format(FlyConfiguration.ConceptSchemeFormat, _foundedDataflowId), gdf.GetConceptList(_foundedDataflowId));
                }
                if (!this.ReferencesObject.Concepts.ContainsKey(ConceptSchemeId))
                {
                    throw new Exception("ConceptScheme not found");
                }

                List <IConceptObjectImpl> conceptsObject = this.ReferencesObject.Concepts[ConceptSchemeId];
                if (!this.parsingObject.ReturnStub)
                {
                    foreach (IConceptObjectImpl _concept in conceptsObject)
                    {
                        //Cerco la giusta Codelist
                        ICodelistMutableObject _CodelistAssociata = null;
                        if (this.ReferencesObject.Codelists != null)
                        {
                            _CodelistAssociata = this.ReferencesObject.Codelists.Find(cl => cl.Id.ToUpper() == _concept.CodelistCode);
                        }
                        // CodelistBuilder _CodelistAssociata = this._Codelists.Find(cl => cl.Concept.ConceptObjectCode == _concept.ConceptObjectCode);
                        //Capire se è un attribute/Dimension
                        if (_CodelistAssociata == null)
                        {
                            CodelistManager cm = new CodelistManager((ISdmxParsingObject)this.parsingObject.Clone(), this.versionTypeResp);
                            if (!String.IsNullOrEmpty(_concept.CodelistCode))
                            {
                                cm.parsingObject.MaintainableId = string.Format(FlyConfiguration.CodelistFormat, _concept.CodelistCode.Substring(3));
                            }
                            else
                            {
                                cm.parsingObject.MaintainableId = null;
                            }
                            cm.parsingObject.QueryDetail = StructureQueryDetailEnumType.AllStubs;
                            cm.BuildCodelist(_foundedDataflowId, _concept);
                            if (cm.ReferencesObject.Codelists != null && cm.ReferencesObject.Codelists.Count > 0)
                            {
                                _CodelistAssociata = cm.ReferencesObject.Codelists[0];
                            }
                        }

                        if (_CodelistAssociata != null)
                        {
                            _concept.ConceptDSDInfo = new ConceptDSDInfoObject()
                            {
                                CodelistId      = _CodelistAssociata.Id,
                                CodelistAgency  = _CodelistAssociata.AgencyId,
                                CodelistVersion = _CodelistAssociata.Version
                            };
                        }

                        switch (_concept.ConceptType)
                        {
                        case ConceptTypeEnum.Dimension:
                            //Se è una Dimension Capire che tipologia di Dimension è Frequency/Time
                            switch (((IDimensionConcept)_concept).DimensionType)
                            {
                            case DimensionTypeEnum.Dimension:
                                DimensionMutableCore dim = new DimensionMutableCore();
                                dim.ConceptRef = ReferenceBuilder.CreateConceptReference(ConceptSchemeId, _concept.Id);
                                dim.Id         = _concept.Id;
                                if (_CodelistAssociata != null)
                                {
                                    dim.Representation = new RepresentationMutableCore()
                                    {
                                        Representation = ReferenceBuilder.CreateCodelistReference(_CodelistAssociata.Id),
                                    };
                                }
                                components.Add(dim);
                                break;

                            case DimensionTypeEnum.Time:
                                DimensionMutableCore TimeDim = new DimensionMutableCore();
                                TimeDim.ConceptRef    = ReferenceBuilder.CreateConceptReference(ConceptSchemeId, _concept.ConceptObjectCode);
                                TimeDim.Id            = _concept.ConceptObjectCode;
                                TimeDim.TimeDimension = true;
                                components.Add(TimeDim);

                                break;

                            case DimensionTypeEnum.Frequency:
                                DimensionMutableCore FreqDim = new DimensionMutableCore();
                                FreqDim.ConceptRef = ReferenceBuilder.CreateConceptReference(ConceptSchemeId, _concept.ConceptObjectCode);
                                if (_CodelistAssociata != null)
                                {
                                    FreqDim.Representation = new RepresentationMutableCore()
                                    {          ////Si da per scontato che la frequency la codelist ce l'abbia
                                        Representation = ReferenceBuilder.CreateCodelistReference(_CodelistAssociata.Id),
                                    };
                                }
                                FreqDim.Id = _concept.ConceptObjectCode;
                                FreqDim.FrequencyDimension = true;

                                if (FreqDim.ConceptRole != null)
                                {
                                    FreqDim.ConceptRole.Add(new StructureReferenceImpl("ESTAT", "ESTAT_CONCEPT_ROLES_SCHEME", "0.1", SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Concept), new List <string> {
                                        "FREQUENCY"
                                    }));
                                }

                                components.Add(FreqDim);
                                break;

                            default:
                                break;
                            }

                            break;

                        case ConceptTypeEnum.Attribute:

                            AttributeMutableCore attr = new AttributeMutableCore();
                            attr.ConceptRef = ReferenceBuilder.CreateConceptReference(ConceptSchemeId, _concept.ConceptObjectCode);
                            if (_CodelistAssociata != null)
                            {
                                IRepresentationMutableObject representation = new RepresentationMutableCore();
                                representation.Representation = ReferenceBuilder.CreateCodelistReference(_CodelistAssociata.Id);
                                attr.Representation           = representation;
                            }
                            //Aggiungo attributi all'attribute AssignmentStatus e AttachmentLevel
                            attr.AssignmentStatus = ((IAttributeConcept)_concept).AssignmentStatusType.ToString();
                            attr.AttachmentLevel  = ((IAttributeConcept)_concept).AttributeAttachmentLevelType;
                            if (attr.AttachmentLevel == AttributeAttachmentLevel.DimensionGroup)
                            {
                                foreach (var dimref in ((IAttributeConcept)_concept).GetDimensionsReference(ReferencesObject.Concepts[ConceptSchemeId]))
                                {
                                    attr.DimensionReferences.Add(dimref);
                                }
                            }
                            if (attr.AttachmentLevel == AttributeAttachmentLevel.Group)
                            {
                                throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.AttributeErrorAttachmentGroup);
                            }

                            //if (_CodelistAssociata.CodesObjects == null || _CodelistAssociata.CodesObjects.Count == 0)
                            //{//levo dall'attribute la referenza alla codelist
                            //    attr.Representation = null;
                            //}

                            if (((IAttributeConcept)_concept).IsValueAttribute)
                            {
                                PrimaryMeasureMutableCore PrimaryMeasure = new PrimaryMeasureMutableCore();    //SdmxStructureType.GetFromEnum(SdmxStructureEnumType.PrimaryMeasure));
                                PrimaryMeasure.ConceptRef = ReferenceBuilder.CreateConceptReference(ConceptSchemeId, _concept.ConceptObjectCode);
                                components.Add(PrimaryMeasure);
                            }
                            else
                            {
                                components.Add(attr);
                            }
                            break;
                        }
                    }
                }
                this.ReferencesObject.Codelists = null;
                DataStructureBuilder _DataStructureBuilder = new DataStructureBuilder(conceptsObject, this.parsingObject, this.versionTypeResp);
                _DataStructureBuilder.Code  = string.Format(FlyConfiguration.DsdFormat, _foundedDataflowId);
                _DataStructureBuilder.Names = new List <SdmxObjectNameDescription>();
                foreach (var nome in ReferencesObject.FoundedDataflows.Find(df => df.Id == _foundedDataflowId).Names)
                {
                    _DataStructureBuilder.Names.Add(new SdmxObjectNameDescription()
                    {
                        Lingua = nome.Locale, Name = nome.Value
                    });
                }

                return(_DataStructureBuilder.BuildDataStructure(components, null, FlyConfiguration.MainAgencyId, FlyConfiguration.Version));
            }
            catch (SdmxException) { throw; }
            catch (Exception ex)
            {
                throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.CreateImmutable, ex);
            }
        }
Exemplo n.º 25
0
 /// <summary>
 /// Add a page reference to a script that initializes a global JavaScript variable with the given data.
 /// </summary>
 /// <param name="globalVariable">The name of the global JavaScript variable to assign.</param>
 /// <param name="data">The data object, serialized into JSON.</param>
 /// <param name="pageLocation">The optional page location of the script. This controls where it will be rendered.</param>
 public static void AddPageData(string globalVariable, object data, string pageLocation = null)
 {
     ReferenceBuilder.Reference(new PageDataScriptBundle(globalVariable, data), pageLocation);
 }
Exemplo n.º 26
0
 internal TryCatchStatement(TryStatement original, ReferenceBuilder type, string name, Statement[] statements) : base(statements)
 {
     this.original = original;
     this.name     = name;
     this.type     = type;
 }
Exemplo n.º 27
0
 internal FullLocalDeclarationStatement(string name, ReferenceBuilder type, Expression initializer, bool is_const) : base(name, initializer)
 {
     this.type     = type;
     this.is_const = is_const;
 }
Exemplo n.º 28
0
 /// <summary>
 /// Adds a page reference to an inline JavaScript block.
 /// </summary>
 /// <param name="scriptContent">The JavaScript code.</param>
 /// <param name="pageLocation">The optional page location of the script. This controls where it will be rendered.</param>
 public static void AddInlineScript(string scriptContent, string pageLocation = null)
 {
     ReferenceBuilder.Reference(new InlineScriptBundle(scriptContent), pageLocation);
 }