Case() public static method

public static Case ( Action, action ) : CaseInfo,
action Action,
return CaseInfo,
Ejemplo n.º 1
0
 private void ValidateRequestSettings(IRequestSettings <T> config, IContactRequest typeRequest)
 {
     TypeSwitch.Do(
         config.mailingProvider,
         TypeSwitch.Case <IIContactRequest>(() => { IContactValidateRequestSettings(config, typeRequest); }),
         TypeSwitch.Default(() => { }));
 }
Ejemplo n.º 2
0
        public override string ConvertTypeToSQLType(Type type, bool preferUnicode = true, string maxLen = "4000")
        {
            string retval = null;

            TypeSwitch.ForType(type,
                               TypeSwitch.Case <char>(() => retval     = preferUnicode ? "CHAR(1) CHARACTER SET ISO8859_1" : "CHAR(1) CHARACTER SET ASCII"),
                               TypeSwitch.Case <string>(() => retval   = (preferUnicode ? "VARCHAR({0}) CHARACTER SET ISO8859_1" : "VARCHAR({0}) CHARACTER SET ASCII").FormatWith(maxLen)),
                               TypeSwitch.Case <byte>(() => retval     = "SMALLINT"),
                               TypeSwitch.Case <bool>(() => retval     = "CHAR(1)"),
                               TypeSwitch.Case <Guid>(() => retval     = "CHAR(16) CHARACTER SET OCTETS"),
                               TypeSwitch.Case <short>(() => retval    = "SMALLINT"),
                               TypeSwitch.Case <int>(() => retval      = "INTEGER"),
                               TypeSwitch.Case <long>(() => retval     = "BIGINT"),
                               TypeSwitch.Case <decimal>(() => retval  = "DECIMAL(18,4)"),
                               TypeSwitch.Case <float>(() => retval    = "FLOAT"),
                               TypeSwitch.Case <double>(() => retval   = "DOUBLE"),
                               TypeSwitch.Case <DateTime>(() => retval = "TIMESTAMP"),
                               TypeSwitch.Case <Byte[]>(() => retval   = "BLOB")
                               );


            if (retval == null)
            {
                throw new SoftwareException("Unable to convert type '{0}' to sql type.", type);
            }

            return(retval);
        }
Ejemplo n.º 3
0
 public override ISQLBuilder Literal(object value)
 {
     if (value != null)
     {
         TypeSwitch.Do(
             value,
             TypeSwitch.Case <byte[]>(x => Emit("X'").Emit(x.ToHexString(true)).Emit("'")),
             TypeSwitch.Case <Guid>(x => this.Literal(x.ToByteArray())),
             TypeSwitch.Case <Guid?>(x => {
             if (x.HasValue)
             {
                 this.Literal(x.Value.ToByteArray());
             }
             else
             {
                 base.Literal(null);
             }
         }),
             TypeSwitch.Default(() => base.Literal(value))
             );
     }
     else
     {
         base.Literal(null);
     }
     return(this);
 }
Ejemplo n.º 4
0
        public override string ConvertTypeToSQLType(Type type, bool preferUnicode = true, string maxLen = "MAX")
        {
            string retval = null;

            TypeSwitch.ForType(type,
                               TypeSwitch.Case <char>(() => retval           = preferUnicode ? "NCHAR" : "CHAR"),
                               TypeSwitch.Case <string>(() => retval         = (preferUnicode ? "NVARCHAR({0})" : "VARCHAR({0})").FormatWith(maxLen)),
                               TypeSwitch.Case <byte>(() => retval           = "TINYINT"),
                               TypeSwitch.Case <bool>(() => retval           = "BIT"),
                               TypeSwitch.Case <Guid>(() => retval           = "UNIQUEIDENTIFIER"),
                               TypeSwitch.Case <short>(() => retval          = "SMALLINT"),
                               TypeSwitch.Case <int>(() => retval            = "INT"),
                               TypeSwitch.Case <long>(() => retval           = "BIGINT"),
                               TypeSwitch.Case <decimal>(() => retval        = "MONEY"),
                               TypeSwitch.Case <float>(() => retval          = "REAL"),
                               TypeSwitch.Case <double>(() => retval         = "FLOAT"),
                               TypeSwitch.Case <DateTime>(() => retval       = "DATETIME"),
                               TypeSwitch.Case <DateTimeOffset>(() => retval = "DATETIMEOFFSET"),
                               TypeSwitch.Case <Byte[]>(() => retval         = "VARBINARY(" + (maxLen ?? "MAX") + ")")
                               );


            if (retval == null)
            {
                throw new SoftwareException("Unable to convert type '{0}' to sql type.", type);
            }

            return(retval);
        }
        public static void Write(this MenuSuiteNode node, CSideWriter writer)
        {
            writer.Write("{ ");
            writer.Write(node.NodeTypeAsString());
            writer.Write(";");
            writer.Write("[{0}] ", node.ID.ToString("B").ToUpper());
            writer.Write(";");

            writer.Indent(writer.Column);

            IEnumerable <Property> properties = null;

            TypeSwitch.Do(
                node,
                TypeSwitch.Case <RootNode>(n => properties  = n.Properties),
                TypeSwitch.Case <MenuNode>(n => properties  = n.Properties),
                TypeSwitch.Case <GroupNode>(n => properties = n.Properties),
                TypeSwitch.Case <ItemNode>(n => properties  = n.Properties),
                TypeSwitch.Case <DeltaNode>(n => properties = n.Properties)
                );

            var relevantProperties = properties.Where(p => p.HasValue);

            relevantProperties.Write(PropertiesStyle.Field, writer);

            writer.Unindent();
            writer.WriteLine("}");
        }
Ejemplo n.º 6
0
        public static string Beautify(object obj)
        {
            var val = string.Empty;

            if (obj != null)
            {
                TypeSwitch.Do(obj,
                              TypeSwitch.Case <string>(s => val     = s),
                              TypeSwitch.Case <DateTime?>(dt => val = string.Format("{0:yyyy-MM-dd HH:mm:ss}", dt)),
                              TypeSwitch.Case <DateTime>(dt => val  = string.Format("{0:yyyy-MM-dd HH:mm:ss}", dt)),
                              //TypeSwitch.Case<byte[]>(b => val =  BitcoinProtocolHelper.BytesToString(b)),
                              TypeSwitch.Case <decimal?>(d => val = string.Format("{0:0.#############################}", d)),
                              TypeSwitch.Case <decimal>(d => val  = string.Format("{0:0.#############################}", d)),
                              TypeSwitch.Case <double?>(d => val  = string.Format("{0:0.#############################}", d)),
                              TypeSwitch.Case <double>(d => val   = string.Format("{0:0.#############################}", d)),
                              TypeSwitch.Case <float?>(d => val   = string.Format("{0:0.#############################}", d)),
                              TypeSwitch.Case <float>(d => val    = string.Format("{0:0.#############################}", d)),
                              TypeSwitch.Default(() => val        = obj.ToString())
                              );
            }
            else
            {
                val = string.Empty;
            }
            return(val);
        }
Ejemplo n.º 7
0
        private void RegisterMultipleComponentsRegistration(ComponentRegistryDefinition componentRegistryDefinition, ComponentRegistryDefinition.ComponentSetRegistrationDefinition componentSetRegistrationDefinition)
        {
            if (componentSetRegistrationDefinition.RegistrationsDefinition == null)
            {
                return;
            }

            foreach (var registration in componentSetRegistrationDefinition.RegistrationsDefinition)
            {
                TypeSwitch.Do(registration,
                              TypeSwitch.Case <ComponentRegistryDefinition.ComponentRegistrationDefinition>(componentRegistration => {
                    componentRegistration.Interface = componentSetRegistrationDefinition.Interface;
                    RegisterMutipleComponentComponentRegistration(
                        componentRegistryDefinition,
                        componentRegistration
                        );
                }),
                              TypeSwitch.Case <ComponentRegistryDefinition.ProxyInterfaceRegistrationDefinition>(proxyRegistration => {
                    proxyRegistration.Interface = componentSetRegistrationDefinition.Interface;
                    RegisterMultipleComponentProxyRegistration(
                        componentRegistryDefinition,
                        proxyRegistration
                        );
                }),
                              TypeSwitch.Default(() => { throw new NotSupportedException(registration.GetType().FullName); })
                              );
            }
        }
Ejemplo n.º 8
0
        public void TypeSwitch_Do_WhenCaseActionNull_ExpectCallAction_Success()
        {
            Action action = null;
            var    case1  = TypeSwitch.Case <object>(action);

            case1.Action.Invoke(null);
        }
Ejemplo n.º 9
0
        private static void Traverse(IGenericObject genericObject, IApp app)
        {
            if (genericObject == null)
            {
                return;
            }

            // Check if the object is an extensions of a master object.
            if (genericObject.Properties.ExtendsObject != null)
            {
                var masterObject = (IMasterObject)genericObject.Properties.ExtendsObject;
                TextHelper.WriteLine(4, "MasterObject version " + masterObject.Properties.MasterVersion);
            }

            // The information to print for each object depends on the type of the object. The TypeSwitch class can be used
            // for this purpose. For extensions of master objects, property values will automatically be retrieved from the
            // master object.
            TypeSwitch.Do(genericObject,
                          TypeSwitch.Case <Table>(o => TextHelper.Print(o.GetType().Name, o.Properties.HyperCubeDef, o.Title, app)),
                          TypeSwitch.Case <Barchart>(o => TextHelper.Print(o.GetType().Name, o.Properties.HyperCubeDef, o.Title, app)),
                          TypeSwitch.Case <Linechart>(o => TextHelper.Print(o.GetType().Name, o.Properties.HyperCubeDef, o.Title, app)),
                          TypeSwitch.Case <Piechart>(o => TextHelper.Print(o.GetType().Name, o.Properties.HyperCubeDef, o.Title, app)),
                          TypeSwitch.Case <Scatterplot>(o => TextHelper.Print(o.GetType().Name, o.Properties.HyperCubeDef, o.Title, app)),
                          TypeSwitch.Case <Treemap>(o => TextHelper.Print(o.GetType().Name, o.Properties.HyperCubeDef, o.Title, app)),
                          TypeSwitch.Case <Gauge>(o => TextHelper.Print(o.GetType().Name, o.Properties.HyperCubeDef, o.Title, app)),
                          TypeSwitch.Case <Combochart>(o => TextHelper.Print(o.GetType().Name, o.Properties.HyperCubeDef, o.Title, app)),
                          TypeSwitch.Case <TextImage>(o => TextHelper.Print(o.GetType().Name, o.Properties.HyperCubeDef, o.Title, app)),
                          TypeSwitch.Case <Listbox>(o => TextHelper.Print(o.GetType().Name, o.Title)),
                          TypeSwitch.Case <Filterpane>(o => TextHelper.Print(o.GetType().Name, o.Title)),
                          TypeSwitch.Case <Kpi>(o => TextHelper.Print(o.GetType().Name, o.Title)),
                          TypeSwitch.Case <Pivottable>(o => TextHelper.Print(o.GetType().Name, o.Title)),
                          TypeSwitch.Case <Map>(o => TextHelper.Print(o.GetType().Name, o.Title)),
                          TypeSwitch.Default(() => TextHelper.WriteLine(4, "Unknown type: " + genericObject.GetType().FullName))
                          );
        }
Ejemplo n.º 10
0
        public virtual string ConvertTypeToSQLType(Type type, bool preferUnicode = true, string maxLen = "4000")
        {
            string retval = null;

            TypeSwitch.ForType(type,
                               TypeSwitch.Case <Char>(() => retval     = preferUnicode ? "NCHAR" : "CHAR"),
                               TypeSwitch.Case <String>(() => retval   = preferUnicode ? "NVARCHAR(MAX)" : "VARCHAR(MAX)"),
                               TypeSwitch.Case <Byte>(() => retval     = "TINYINT"),
                               TypeSwitch.Case <Boolean>(() => retval  = "BIT"),
                               TypeSwitch.Case <Guid>(() => retval     = "UNIQUEIDENTIFIER"),
                               TypeSwitch.Case <Int16>(() => retval    = "SMALLINT"),
                               TypeSwitch.Case <Int32>(() => retval    = "INT"),
                               TypeSwitch.Case <Int64>(() => retval    = "BIGINT"),
                               TypeSwitch.Case <Decimal>(() => retval  = "MONEY"),
                               TypeSwitch.Case <Single>(() => retval   = "REAL"),
                               TypeSwitch.Case <Double>(() => retval   = "FLOAT"),
                               TypeSwitch.Case <DateTime>(() => retval = "DATETIME")
                               );


            if (retval == null)
            {
                throw new SoftwareException("Unable to convert type '{0}' to sql type.", type);
            }

            return(retval);
        }
Ejemplo n.º 11
0
        public void TypeSwitch_Case_Generic_ActionIsNotNull_Success()
        {
            var result = TypeSwitch.Case(delegate(object o) { });

            result.Action.Invoke(null);
            Assert.AreEqual(typeof(object), result.Target);
            Assert.IsFalse(result.IsDefault);
        }
        /// <summary>
        ///     Az adott "Target Object"-en végrehajt egy állapot visszaállítást. Tehát az objektum
        ///     új értéke, az előzőleg megadott érték lesz.
        ///     (Például: CurrentValue = 20; OldValue = 15; -> Undo -> CurrentValue = 15; OldValue = )
        /// </summary>
        /// <param name="eventType">
        ///     Az az esemény típus amely meghatározza, hogy a TargetObject-en milyen típusú végrehajtott
        ///     eseményeket kell kiválasztani, majd meghatározza, hogy melyik esemény "Parancsot" kell
        ///     visszavonni.
        /// </param>
        public void UndoLast(object eventType)
        {
            List <object> currentEventTypeList = _personEventBrokerHelpers.FillCurrentEventTypeList(eventType.GetType(), this.AllEvents);

            TypeSwitch.Do(eventType,
                          TypeSwitch.Case <AgeChangedEvent>(() => _personUndoMethods.UndoLastAgeChanged(currentEventTypeList, AllEvents, this)),
                          TypeSwitch.Case <NameChangedEvent>(() => _personUndoMethods.UndoLastNameChanged(currentEventTypeList, AllEvents, this)));
        }
Ejemplo n.º 13
0
 public void DoSelectsCorrectCase()
 {
     TypeSwitch.Do <int>(
         TypeSwitch.Case <string>(() => Assert.That(false, "Expected int, got string")),
         TypeSwitch.Case <bool>(() => Assert.That(false, "Expected int, got bool")),
         TypeSwitch.Case <int>(() => {}),
         TypeSwitch.Case <float>(() => Assert.That(false, "Expected int, got float"))
         );
 }
Ejemplo n.º 14
0
        public void TypeSwitch_Do_WhenCaseGeneric_ExpectNotDefaultAndTargetEqualsObject()
        {
            //------------Execute Test---------------------------
            var result = TypeSwitch.Case <object>(delegate(object o) { });

            //------------Assert Results-------------------------
            Assert.AreEqual(typeof(object), result.Target);
            Assert.IsFalse(result.IsDefault);
        }
 public static void Write(this PageControlBase pageControl, CSideWriter writer, int propertyIndentation)
 {
     TypeSwitch.Do(
         pageControl,
         TypeSwitch.Case <PageControlContainer>(c => c.Write(writer, propertyIndentation)),
         TypeSwitch.Case <PageControlGroup>(c => c.Write(writer, propertyIndentation)),
         TypeSwitch.Case <PageControlPart>(c => c.Write(writer, propertyIndentation)),
         TypeSwitch.Case <PageControl>(c => c.Write(writer, propertyIndentation)));
 }
Ejemplo n.º 16
0
 public void DoDoesNothingIfTypesDoNotMatchAndNoDefaultCaseExists()
 {
     TypeSwitch.Do <object>(
         TypeSwitch.Case <string>(() => Assert.That(false, "Expected default case, got string")),
         TypeSwitch.Case <bool>(() => Assert.That(false, "Expected default case, got bool")),
         TypeSwitch.Case <int>(() => Assert.That(false, "Expected default case, got int")),
         TypeSwitch.Case <float>(() => Assert.That(false, "Expected default case, got float"))
         );
 }
Ejemplo n.º 17
0
        public static IDev2TOFn CreateNewDTO(IDev2TOFn dto, int index = 0, bool inserted = false, string initializeWith = "")
        {
            IDev2TOFn toReturn = null;

            TypeSwitch.Do(dto,
                          // ReSharper disable ImplicitlyCapturedClosure
                          TypeSwitch.Case <ActivityDTO>(x => toReturn = new ActivityDTO(initializeWith, "", index, inserted)),
                          // ReSharper restore ImplicitlyCapturedClosure
                          TypeSwitch.Case <DataSplitDTO>(x =>
            {
                var dataSplitDto = dto as DataSplitDTO;
                if (dataSplitDto != null)
                {
                    toReturn = new DataSplitDTO(initializeWith, dataSplitDto.SplitType, dataSplitDto.At, index, false, inserted);
                }
            }),
                          TypeSwitch.Case <DataMergeDTO>(x =>
            {
                var dataMergeDto = dto as DataMergeDTO;
                if (dataMergeDto != null)
                {
                    toReturn = new DataMergeDTO(initializeWith, dataMergeDto.MergeType, dataMergeDto.At, index, dataMergeDto.Padding, dataMergeDto.Alignment, inserted);
                }
            }),
                          TypeSwitch.Case <CaseConvertTO>(x =>
            {
                var caseConvertTO = dto as CaseConvertTO;
                if (caseConvertTO != null)
                {
                    toReturn = CaseConverterFactory.CreateCaseConverterTO(initializeWith, caseConvertTO.ConvertType, caseConvertTO.Result, index);
                }
            }),
                          TypeSwitch.Case <BaseConvertTO>(x =>
            {
                var baseConvertTO = dto as BaseConvertTO;
                if (baseConvertTO != null)
                {
                    toReturn = new BaseConvertTO(initializeWith, baseConvertTO.FromType, baseConvertTO.ToType, baseConvertTO.ToExpression, index, inserted);
                }
            }),
                          // ReSharper disable ImplicitlyCapturedClosure
                          TypeSwitch.Case <GatherSystemInformationTO>(x => toReturn =
                                                                          // ReSharper restore ImplicitlyCapturedClosure
                                                                          new GatherSystemInformationTO(enTypeOfSystemInformationToGather.FullDateTime,
                                                                                                        initializeWith, index, inserted)),
                          // ReSharper disable ImplicitlyCapturedClosure
                          TypeSwitch.Case <XPathDTO>(x => toReturn = new XPathDTO(initializeWith, "", index, inserted)),
                          // ReSharper restore ImplicitlyCapturedClosure
                          // ReSharper disable ImplicitlyCapturedClosure
                          TypeSwitch.Case <FindRecordsTO>(() => toReturn = new FindRecordsTO("", "", index, inserted)),
                          // ReSharper restore ImplicitlyCapturedClosure
                          // ReSharper disable ImplicitlyCapturedClosure
                          TypeSwitch.Default(() => toReturn = null));
            // ReSharper restore ImplicitlyCapturedClosure

            return(toReturn);
        }
Ejemplo n.º 18
0
        public void TypeSwitch_Case_Generic_ActionIsNull_Success()
        {
            Action <object> action = null;
            var             result = TypeSwitch.Case(action);

            result.Action.Invoke(null);

            Assert.AreEqual(typeof(object), result.Target);
            Assert.IsFalse(result.IsDefault);
        }
Ejemplo n.º 19
0
 private void ConfigureRequest(HttpWebRequest request, IRequestSettings <T> config)
 {
     TypeSwitch.Do(
         config.mailingProvider,
         TypeSwitch.Case <IIContactRequest>(() => {
         //IContactConfigureRequest(request, config);
         IContactConfigureRequestJson(request, config);
     }),
         TypeSwitch.Default(() => { }));
 }
Ejemplo n.º 20
0
        public void CaseCreatesCaseInfoObjectCorrectly()
        {
            Action action = () => {};

            var result = TypeSwitch.Case <int>(action);

            Assert.AreEqual(result.IsDefault, false);
            Assert.AreEqual(result.Target, typeof(int));
            Assert.AreEqual(result.Action, action);
        }
Ejemplo n.º 21
0
        public static void Write(this FormControlBase formControl, CSideWriter writer, int propertyIndentation)
        {
            TypeSwitch.Do(
                formControl,

                /*TypeSwitch.Case<PageControlContainer>(c => c.Write(writer, propertyIndentation)),
                 * TypeSwitch.Case<PageControlGroup>(c => c.Write(writer, propertyIndentation)),
                 * TypeSwitch.Case<PageControlPart>(c => c.Write(writer, propertyIndentation)),*/
                //TypeSwitch.Case<FormMenuButtonControl>(m => m.Write(writer, propertyIndentation)),
                TypeSwitch.Case <FormControl>(c => c.Write(writer, propertyIndentation)));
        }
Ejemplo n.º 22
0
        public static void Write(this ReportElement reportElement, CSideWriter writer)
        {
            string type = null;

            TypeSwitch.Do(
                reportElement,
                TypeSwitch.Case <DataItemReportElement>(e => type = "DataItem"),
                TypeSwitch.Case <ColumnReportElement>(e => type   = "Column"));

            var debt               = 0;
            var elementID          = BuildReportElementPart(reportElement.ID.ToString(), 4, ref debt);
            var elementIndentation = BuildReportElementPart(reportElement.IndentationLevel.AsString(), 4, ref debt);
            var elementType        = BuildReportElementPart(type, 8, ref debt);
            var elementName        = BuildReportElementPart(reportElement.Name ?? string.Empty, 20, ref debt);
            var declaration        = string.Format("{{ {0};{1};{2};{3}", elementID, elementIndentation, elementType, elementName);

            writer.Write(declaration);
            writer.Indent(15);

            IEnumerable <Property> properties = null;

            TypeSwitch.Do(
                reportElement,
                TypeSwitch.Case <DataItemReportElement>(e => properties = e.Properties),
                TypeSwitch.Case <ColumnReportElement>(e => properties   = e.Properties));

            var relevantProperties = properties.Where(p => p.HasValue);

            switch (relevantProperties.Any())
            {
            case true:
                writer.WriteLine(";");
                relevantProperties.Write(PropertiesStyle.Field, writer);
                break;

            default:
                writer.Write(" ");
                break;
            }

            var lastProperty = relevantProperties.LastOrDefault();

            if (lastProperty != null)
            {
                if (lastProperty is TriggerProperty)
                {
                    writer.Write(new string(' ', lastProperty.Name.Length + 2));
                }
            }

            writer.WriteLine("}");
            writer.Unindent();
            writer.InnerWriter.WriteLine();
        }
Ejemplo n.º 23
0
        private string CreatetUriRequest(T mailingProvider, IContactRequest typeRequest)
        {
            string uri = string.Empty;

            TypeSwitch.Do(
                mailingProvider,
                TypeSwitch.Case <IIContactRequest>(() => { uri = IContactCreatetUriRequest(mailingProvider, typeRequest); }),
                TypeSwitch.Default(() => { uri = string.Empty; }));

            return(uri);
        }
 void OnReturnInstanceSignalDispatched(PoolableView view)
 {
     TypeSwitch.Do(
         view,
         TypeSwitch.Case <PlayerShipLaserView>(x => playerLaserPool.ReturnInstance(x)),
         TypeSwitch.Case <AsteroidView>(x => asteroidPool.ReturnInstance(x)),
         TypeSwitch.Case <EnemyShipView>(x => enemyShipPool.ReturnInstance(x)),
         TypeSwitch.Default(() => {
         throw new NotSupportedException("This view can not supported!!!!!");
     })
         );
 }
Ejemplo n.º 25
0
        public void TypeSwitch_Do_WhenCaseActionNotNull_ExpectActionSet()
        {
            var wasCalled = false;
            var action    = new Action(delegate { wasCalled = true; });
            var case1     = TypeSwitch.Case <object>(action);

            var obj = new object();

            TypeSwitch.Do(obj, case1);

            Assert.IsTrue(wasCalled, "expected action to be called");
        }
Ejemplo n.º 26
0
        private static Dictionary <string, string> GetFieldValues(object sender)
        {
            var layer = sender as iLayer;

            if (layer == null)
            {
                return(null);
            }
            var parameters = new Dictionary <string, string>();
            var typeSwitch = new TypeSwitch();

            foreach (var field in layer.Items.OfType <Fieldset>().SelectMany(f => f).Where(f => f.ID != null))
            {
                typeSwitch.Object = field;
                typeSwitch
                .Case <SelectListField>(c =>
                {
                    parameters[c.ID]          = c.SelectedValue;
                    parameters[c.ID + ".Key"] = c.SelectedKey;
                })
                .Case <BoolField>(c => parameters[c.ID] = c.Value ? "on" : "off")
                .Case <DateField>(f =>
                {
                    if (f.Value == null)
                    {
                        parameters[f.ID] = string.Empty;
                    }
                    else
                    {
                        switch (f.Type)
                        {
                        case DateField.DateType.Date:
                            parameters[f.ID] = f.Value.Value.ToString("d");
                            break;

                        case DateField.DateType.Time:
                            parameters[f.ID] = f.Value.Value.ToString("t");
                            break;

                        default:
                            parameters[f.ID] = f.Value.Value.ToString("g");
                            break;
                        }
                    }
                })
                .Case <DrawingField>(c => parameters[c.ID] = c.DrawnImageId ?? string.Empty)
                .Case <SliderField>(c => parameters[c.ID]  = c.Value.ToString())
                .Case <LabelField>(f => f.Text.IsNullOrEmptyOrWhiteSpace(), c => parameters[c.ID] = c.Label ?? string.Empty)
                .Case <Field>(f => parameters[f.ID] = f.Text ?? string.Empty);
            }

            return(parameters);
        }
Ejemplo n.º 27
0
 public static void Write(this XmlPortNode xmlPortNode, CSideWriter writer)
 {
     TypeSwitch.Do(
         xmlPortNode,
         TypeSwitch.Case <XmlPortTextElement>(n => n.Write(writer)),
         TypeSwitch.Case <XmlPortTextAttribute>(n => n.Write(writer)),
         TypeSwitch.Case <XmlPortTableElement>(n => n.Write(writer)),
         TypeSwitch.Case <XmlPortTableAttribute>(n => n.Write(writer)),
         TypeSwitch.Case <XmlPortFieldElement>(n => n.Write(writer)),
         TypeSwitch.Case <XmlPortFieldAttribute>(n => n.Write(writer))
         );
 }
Ejemplo n.º 28
0
        public virtual ISQLBuilder Literal(object value)
        {
            if (value == null || value == DBNull.Value)
            {
                return(Emit("NULL"));
            }

            TypeSwitch.Do(value,
                          TypeSwitch.Case <SQLBuilderCommand>(c => { c.Execute(this.LeafBuilder); }),
                          TypeSwitch.Default(() => Emit(value.ToSQLString()))
                          );
            return(this);
        }
Ejemplo n.º 29
0
        private IDataType GetDataType()
        {
            var dataType = string.Empty;

            TypeSwitch.Do(
                CurrentColumnInfo.Column.FieldNameType,
                TypeSwitch.Case <string>(() => dataType    = "StringDataType"),
                TypeSwitch.Case <DateTime>(() => dataType  = "DatetimeDataType"),
                TypeSwitch.Case <DateTime?>(() => dataType = "DatetimeDataType"),
                TypeSwitch.Default(() => dataType          = "DefaultType")
                );
            return(DataTypeFactory.GetInstance().CreateInstance(dataType));
        }
Ejemplo n.º 30
0
        public static IDev2TOFn CreateNewDTO(IDev2TOFn dto, int index, bool inserted, string initializeWith)
        {
            IDev2TOFn toReturn = null;

            TypeSwitch.Do(dto,

                          TypeSwitch.Case <ActivityDTO>(x => toReturn = new ActivityDTO(initializeWith, "", index, inserted)),

                          TypeSwitch.Case <DataSplitDTO>(x =>
            {
                if (dto is DataSplitDTO dataSplitDto)
                {
                    toReturn = new DataSplitDTO(initializeWith, dataSplitDto.SplitType, dataSplitDto.At, index, false, inserted);
                }
            }),
                          TypeSwitch.Case <DataMergeDTO>(x =>
            {
                if (dto is DataMergeDTO dataMergeDto)
                {
                    toReturn = new DataMergeDTO(initializeWith, dataMergeDto.MergeType, dataMergeDto.At, index, dataMergeDto.Padding, dataMergeDto.Alignment, inserted);
                }
            }),
                          TypeSwitch.Case <CaseConvertTO>(x =>
            {
                if (dto is CaseConvertTO caseConvertTO)
                {
                    toReturn = CaseConverterFactory.CreateCaseConverterTO(initializeWith, caseConvertTO.ConvertType, caseConvertTO.Result, index);
                }
            }),
                          TypeSwitch.Case <BaseConvertTO>(x =>
            {
                if (dto is BaseConvertTO baseConvertTO)
                {
                    toReturn = new BaseConvertTO(initializeWith, baseConvertTO.FromType, baseConvertTO.ToType, baseConvertTO.ToExpression, index, inserted);
                }
            }),

                          TypeSwitch.Case <GatherSystemInformationTO>(x => toReturn =
                                                                          new GatherSystemInformationTO(enTypeOfSystemInformationToGather.FullDateTime,
                                                                                                        initializeWith, index, inserted)),
                          TypeSwitch.Case <XPathDTO>(x => toReturn              = new XPathDTO(initializeWith, "", index, inserted)),
                          TypeSwitch.Case <FindRecordsTO>(() => toReturn        = new FindRecordsTO("", "", index, inserted)),
                          TypeSwitch.Case <DecisionTO>(() => toReturn           = new DecisionTO(initializeWith, "", "", index, inserted)),
                          TypeSwitch.Case <JsonMappingTo>(() => toReturn        = new JsonMappingTo(initializeWith, index, inserted)),
                          TypeSwitch.Case <SharepointSearchTo>(() => toReturn   = new SharepointSearchTo(initializeWith, "=", "", index, inserted)),
                          TypeSwitch.Case <SharepointReadListTo>(() => toReturn = new SharepointReadListTo("", initializeWith, "", "")),
                          TypeSwitch.Case <AssignObjectDTO>(x => toReturn       = new AssignObjectDTO(initializeWith, "", index, inserted)),
                          TypeSwitch.Default(() => toReturn = null));

            return(toReturn);
        }