/// <summary> /// Return lambda value for param "Value",null elsewhere /// </summary> /// <param name="Value"></param> /// <param name="Default"></param> /// <returns></returns> public static Int32?FillOrDefault(Func <MobProperty, dynamic> Lambda, MobProperty Value) { if (Value == null || Value.IsNull) { return(null); } return(Convert.ToInt32(Lambda.Invoke(Value))); }
public override _SubDevice Extend(dynamic wprObj) { List <WprManagementObject> obj = wprObj as List <WprManagementObject>; WprManagementObject current = obj.Where(d => d.GetProperty("DeviceID").AsSubString(3, 1).Equals(Name.AsSubString(0, 1))).FirstOrDefault(); MaxSpeed = current == null ? null : current.GetProperty("MaxClockSpeed"); if (MaxSpeed == null || PercentProcessorPerformance == null) // use base frequency for tboost { Frequency = ProcessorFrequency; } else { Frequency = new MobProperty((MaxSpeed.AsInt() / 100) * PercentProcessorPerformance.AsInt()); } return(this); }
public override _SubDevice Extend() { UInt64?Den; if (BytesTotalPersec.AsString() != null) { Den = BytesTotalPersec.AsUInt64() / 100; if (Den != 0) { UInt64?percentBytesReceived = BytesReceivedPersec.AsString() != null?BytesReceivedPersec.AsUInt64() / Den : null; PercentBytesReceived = new MobProperty(percentBytesReceived); UInt64?percentBytesSent = BytesSentPersec.AsString() != null?BytesSentPersec.AsUInt64() / Den : null; PercentBytesSent = new MobProperty(percentBytesSent); } else { PercentBytesReceived = new MobProperty("0"); PercentBytesSent = new MobProperty("0"); } } else { PercentBytesReceived = new MobProperty(null); PercentBytesSent = new MobProperty(null); } if (PacketsPersec.AsString() != null) { Den = PacketsPersec.AsUInt64() / 100; if (Den != 0) { UInt64?percentPacketsReceived = PacketsReceivedPersec.AsString() != null?PacketsReceivedPersec.AsUInt64() / Den : null; PercentPacketsReceived = new MobProperty(percentPacketsReceived); UInt64?percentPacketsSents = PacketsSentPersec.AsString() != null?PacketsSentPersec.AsUInt64() / Den : null; PercentPacketsSents = new MobProperty(percentPacketsSents); } else { PercentPacketsSents = new MobProperty("0"); PercentPacketsReceived = new MobProperty("0"); } } else { PercentPacketsReceived = new MobProperty(null); PercentPacketsSents = new MobProperty(null); } var mjx = new WprManagementObjectSearcher("Win32_PerfRawData_Tcpip_NetworkAdapter").First(x => x.GetProperty("Name").AsString().Equals(Name.AsString())) ?? new WprManagementObject(); TotalBytesReceived = mjx.GetProperty("BytesReceivedPersec"); TotalBytesSent = mjx.GetProperty("BytesSentPersec"); TotalBytes = mjx.GetProperty("BytesTotalPersec"); return(this); }
public override _SubDevice Extend() { PerUsage = (CommitLimit.IsNull || AvailableBytes.IsNull) ? new MobProperty(null) : new MobProperty(CommittedBytes.AsUInt64() / (CommitLimit.AsUInt64() / 100)); return(this); }
/// <summary> /// Return passed "Value", null elsewhere /// </summary> /// <param name="Value"></param> /// <param name="Default"></param> /// <returns></returns> public static int?FillOrDefault(MobProperty Value) { return((Value == null || Value.IsNull) ? null : Value.AsInt32()); }
/// <summary> /// Return a lambda value for param "Value" with the specified string format, "Default" string elsewhere /// </summary> /// <param name="Value"></param> /// <param name="Default"></param> /// <returns></returns> public static String AsDefaultValue(Func <MobProperty, dynamic> Function, MobProperty Value, String Default, String Format) { return((Value == null || Value.IsNull) ? Default : string.Format(Format, Convert.ToDouble(Function.Invoke(Value)))); }
/// <summary> /// Return lambda value for param "Value", "Default" string elsewhere /// </summary> /// <param name="Value"></param> /// <param name="Default"></param> /// <returns></returns> public static String AsDefaultValue(Func <MobProperty, dynamic> Lambda, MobProperty Value, String Default) { return((Value == null || Value.IsNull) ? Default : Lambda.Invoke(Value).ToString()); }
/// <summary> /// Return passed "Value" with the specified format, "Default" string elsewhere /// </summary> /// <param name="Value"></param> /// <param name="Default"></param> /// <returns></returns> public static String AsDefaultValue(MobProperty Value, String Default, String Format) { return((Value == null || Value.IsNull) ? Default : string.Format(Format, Value.AsDouble())); }
/// <summary> /// Return passed "Value", "Default" string elsewhere /// </summary> /// <param name="Value"></param> /// <param name="Default"></param> /// <returns></returns> public static String AsDefaultValue(MobProperty Value, String Default) { return((Value == null || Value.IsNull) ? Default : Value.AsString()); }