private int GetValueIndexForProperty(string property) { int propertyIndex = rawValue.IndexOf(property, StringComparison.Ordinal); if (propertyIndex == -1) { return(-1); } CharEnumerator it = rawValue.GetEnumerator(); int counter = 0; while (counter <= propertyIndex + property.Length) { it.MoveNext(); counter++; } while (it.Current == ' ' || it.Current == ':') { it.MoveNext(); counter++; } counter--; it.Dispose(); return(counter); }
/// <summary> /// Dispose /// </summary> public void Dispose() { if (charStream != null) { charStream.Dispose(); } else { charStream2.Dispose(); } }
protected virtual void Dispose(bool disposing) { if (!_disposing) { if (disposing) { _charEnumerator.Dispose(); } // shared cleanup logic _disposing = true; } }
public bool Equals(string other, char joinCharacter) { if (other == null) { return(false); } Enumerator fe = new Enumerator(this, joinCharacter); CharEnumerator ce = other.GetEnumerator(); do { if (fe.MoveNext()) { if (!ce.MoveNext()) { break; } } else if (ce.MoveNext()) { break; } else { fe.Dispose(); ce.Dispose(); return(true); } }while (fe.Current == ce.Current); fe.Dispose(); ce.Dispose(); return(false); }
public void Dispose() { charEnumerator.Dispose(); }
public void Dispose() => Enumerator.Dispose();
private object fCreateLisEnum(string aString, Type aType) { object[] flagsAttribs = aType.GetCustomAttributes(typeof(FlagsAttribute), inherit: false); if ((int)flagsAttribs.LongLength > 0) { string inputString = string.Empty; string enumStringValue = null; int i = 0; FieldInfo[] fields = aType.GetFields(); if (fields != null) { for (; i < (int)fields.LongLength; i++) { FieldInfo fi = fields[i]; LisEnumAttribute[] attribs = fi.GetCustomAttributes(typeof(LisEnumAttribute), inherit: false) as LisEnumAttribute[]; if ((int)attribs.LongLength > 0) { enumStringValue = attribs[0].LisID; } if (aString == null) { continue; } CharEnumerator enumerator = aString.GetEnumerator(); if (enumerator == null) { continue; } try { while (enumerator.MoveNext()) { char ch = enumerator.Current; if (string.Compare(enumStringValue, new string(ch, 1), ignoreCase: true) == 0) { inputString = inputString + fi.Name + ","; } } } finally { enumerator.Dispose(); } } } if (inputString.Length > 0) { inputString = inputString.Remove(inputString.Length - 1, 1); return(Enum.Parse(aType, inputString)); } } else { string inputString = null; int i = 0; FieldInfo[] fields = aType.GetFields(); if (fields != null) { for (; i < (int)fields.LongLength; i++) { FieldInfo fi = fields[i]; LisEnumAttribute[] attribs = fi.GetCustomAttributes(typeof(LisEnumAttribute), inherit: false) as LisEnumAttribute[]; if ((int)attribs.LongLength > 0) { inputString = attribs[0].LisID; } if (string.Compare(inputString, aString, ignoreCase: true) == 0) { return(Enum.Parse(aType, fi.Name)); } } } } object Result = default(object); return(Result); }
public void UpdateValue(string val, int idx, int masterViewColumnCount) { if (val != string.Empty) { lock (_rowLock) { // adjust for master and child view differences ;) AdjustStorage(masterViewColumnCount); int start = _startIdx[idx]; if (start > DataListConstants.EmptyRowStartIdx) { // we have data, cool beans ;) if (val == null) { _startIdx[idx] = DataListConstants.EmptyRowStartIdx; } else { int candiateLen = val.Length; int len = _columnLen[idx]; // if candidate is larger then prev value, we need to append to end of storage ;) if (candiateLen > len) { // do we have space int requiredSize = (_usedStorage + candiateLen); if (requiredSize >= _storageCapacity) { // Nope, grow array GrowRow(requiredSize); } // else yes we have the space, but in either case we need to append to end ;) start = FetchStorageStartIdx(); int pos = 0; int iterationLen = (start + candiateLen); for (int i = start; i < iterationLen; i++) { _rowData[i] = val[pos]; pos++; } // finally update the storage location data _startIdx[idx] = start; _columnLen[idx] = candiateLen; _usedStorage += candiateLen; } else { // same size or small we can fit it into the same location // first update data int pos = 0; int overWriteLen = (start + candiateLen); for (int i = start; i < overWriteLen; i++) { _rowData[i] = val[pos]; pos++; } // finally update length array ;) _columnLen[idx] = candiateLen; } } } else { // It is a new value that needs to be inserted ;) if (val == null) { _startIdx[idx] = DataListConstants.EmptyRowStartIdx; } else { int canidateLen = val.Length; int storageReq = _usedStorage + canidateLen; if (storageReq >= _storageCapacity) { // sad panda, we need to grow the storage GrowRow(storageReq); } // now we have space, it is time to save the value ;) start = FetchStorageStartIdx(); CharEnumerator itr = val.GetEnumerator(); int iterateLen = (start + canidateLen); for (int i = start; i < iterateLen; i++) { itr.MoveNext(); _rowData[i] = itr.Current; } itr.Dispose(); // finally, update the storage data _startIdx[idx] = start; _columnLen[idx] = canidateLen; _usedStorage += canidateLen; } } } } else { // clear the existing storage requirements out ;) if (idx < _colCnt) { _startIdx[idx] = 0; _columnLen[idx] = 0; } } }