Example #1
0
        protected override void Write()
        {
            cw.WriteUsing("System.Runtime.Serialization");
            cw.WriteUsing("System.Collections.Generic");
            cw.WriteCommentLine("Assembly required: ServiceStack.Interfaces.dll");
            cw.WriteUsing("ServiceStack.ServiceHost");
            cw.WriteUsing("ServiceStack.ServiceInterface");
            cw.WriteUsing("ServiceStack.ServiceInterface.ServiceModel");
            cw.WriteLine();

            environment.BaseNamespace = ServicesLayerConfig.ServicesInterfacesNamespace;

            oph   = new OperationHelper(cw, environment);
            intfh = new ServicesInterfacesHelper(cw, environment);

            ns.BeginScope(environment.BaseNamespace);

            Dictionary <string, List <string> > data = new Dictionary <string, List <string> >();
            List <string> patternNames = new List <string>();

            foreach (IPatternConfig pattern in this.genie.Lamp.Config.Patterns)
            {
                patternNames.Add(pattern.Name);
            }
            data.Add("patterns", patternNames);
            if (this.genie.Lamp.Config.Patterns.Localization != null)
            {
                List <string> localizationDetails   = new List <string>();
                string        satelliteAssemblyName = DomainLayerConfig.LocalizationParams.ValueByName("SatelliteAssemblyName", String.Empty);
                if (!String.IsNullOrEmpty(satelliteAssemblyName))
                {
                    satelliteAssemblyName = "\"" + satelliteAssemblyName + "\"";
                }
                localizationDetails.Add(satelliteAssemblyName);
                data.Add("pattern.Localization", localizationDetails);
            }

            string content = GenieLamp.Core.Utils.Text.ReadFromResource(
                this.GetType().Assembly,
                "Templates.ServicesInterfaces.cs");
            var template = new TextTemplate.Template <Dictionary <string, List <string> > >("data");

            template.Content = genie.Config.Macro.Subst(content);             // Substitute all macros before compiling template to avoid errors
            cw.WriteText(template.Execute(data));

//			cw.WriteText(this.GetType().Assembly,
//			             "Templates.ServicesInterfaces.cs",
//			             genie.Config.Macro);
            cw.WriteLine();

            cw.WriteText(this.GetType().Assembly,
                         "Templates.StackServicesInterfaces.cs",
                         genie.Config.Macro);
            cw.WriteLine();

            ProcessEntities();

            ns.EndScope();
        }
        public void WriteParamClassesProperties(IEntity entity)
        {
            ServicesInterfacesHelper intfh = new ServicesInterfacesHelper(cw, environment);

            foreach (IEntityOperation operation in entity.Operations)
            {
                intfh.WriteProperty(GetParamClassName(operation), GetParamClassPropertyName(operation));
            }
        }