示例#1
0
        private EwsValueItem EnsureValueItem(string altId, string name = null, string description = null, EwsValueTypeEnum type = EwsValueTypeEnum.String, EwsContainerItem parent = null, string unit = null, EwsValueWriteableEnum writeable = EwsValueWriteableEnum.Writeable, EwsValueForceableEnum forceable = EwsValueForceableEnum.Forceable, EwsValueStateEnum defaultState = EwsValueStateEnum.Uncertain)
        {
            CheckCancellationToken();

            var vi = DataAdapter.ValueItems.FirstOrDefault(x => x.AlternateId == altId);

            if (vi == null)
            {
                return(DataAdapter.AddValueItem(altId, name ?? altId, description, type, writeable, forceable, defaultState, unit, parent));
            }
            vi = DataAdapter.ModifyValueItemName(vi, altId);
            vi = DataAdapter.ModifyValueItemDescription(vi, description);
            vi = DataAdapter.ModifyValueItemType(vi, type);
            vi = DataAdapter.ModifyValueItemWriteable(vi, writeable);
            vi = DataAdapter.ModifyValueItemForceable(vi, forceable);
            vi = DataAdapter.ModifyValueItemUnit(vi, unit);
            return(DataAdapter.ModifyValueItemParent(vi, parent));
        }